Initial Commit
The initial public commit of MVGL website code.
This commit is contained in:
commit
b39ecf1638
2043 changed files with 215154 additions and 0 deletions
55
database/seeders/PermissionsSeeder.php
Normal file
55
database/seeders/PermissionsSeeder.php
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
|
||||
class PermissionsSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
app()[\Spatie\Permission\PermissionRegistrar::class]->forgetCachedPermissions();
|
||||
|
||||
$data = $this->data();
|
||||
|
||||
foreach ($data as $value) {
|
||||
Permission::create([
|
||||
'name' => $value['name'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function data()
|
||||
{
|
||||
$data = [];
|
||||
// list of model permission
|
||||
$model = ['content', 'user', 'role', 'permission'];
|
||||
|
||||
foreach ($model as $value) {
|
||||
foreach ($this->crudActions($value) as $action) {
|
||||
$data[] = ['name' => $action];
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function crudActions($name)
|
||||
{
|
||||
$actions = [];
|
||||
// list of permission actions
|
||||
$crud = ['create', 'read', 'update', 'delete'];
|
||||
|
||||
foreach ($crud as $value) {
|
||||
$actions[] = $value . ' ' . $name;
|
||||
}
|
||||
|
||||
return $actions;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue