You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.5 KiB
66 lines
1.5 KiB
<?php
|
|
namespace Database\Seeders;
|
|
|
|
use Illuminate\Database\Seeder;
|
|
use Itstructure\LaRbac\Models\Permission;
|
|
|
|
/**
|
|
* Class PermissionSeeder
|
|
*
|
|
* @author Andrey Girnik <girnikandrey@gmail.com>
|
|
*/
|
|
class PermissionSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
* @return void
|
|
*/
|
|
public function run()
|
|
{
|
|
$this->createRecord(
|
|
Permission::ADMINISTRATE_PERMISSION,
|
|
'Total administrate of users and content'
|
|
);
|
|
|
|
$this->createRecord(
|
|
Permission::VIEW_RECORD_PERMISSION,
|
|
'Permission to view record'
|
|
);
|
|
|
|
$this->createRecord(
|
|
Permission::CREATE_RECORD_PERMISSION,
|
|
'Permission to create record'
|
|
);
|
|
|
|
$this->createRecord(
|
|
Permission::UPDATE_RECORD_PERMISSION,
|
|
'Permission to update record'
|
|
);
|
|
|
|
$this->createRecord(
|
|
Permission::DELETE_RECORD_PERMISSION,
|
|
'Permission to delete record'
|
|
);
|
|
|
|
$this->createRecord(
|
|
Permission::PUBLISH_RECORD_PERMISSION,
|
|
'Permission to publish record'
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Create permission record in database.
|
|
* @param string $slug
|
|
* @param string $description
|
|
* @return void
|
|
*/
|
|
private function createRecord(string $slug, string $description): void
|
|
{
|
|
Permission::create([
|
|
'name' => str_replace('-', ' ', ucfirst($slug)),
|
|
'slug' => $slug,
|
|
'description' => $description,
|
|
]);
|
|
}
|
|
}
|