Update Permission Seeder

This commit is contained in:
Daeng Deni Mardaeni 2023-06-08 13:26:13 +07:00
parent 480c12d6f7
commit f05fd25e18
2 changed files with 6 additions and 5 deletions

View File

@ -17,7 +17,7 @@
$data = $this->data(); $data = $this->data();
foreach ($data as $value) { foreach ($data as $value) {
PermissionGroup::create([ PermissionGroup::updateOrCreate([
'name' => $value['name'], 'name' => $value['name'],
]); ]);
} }

View File

@ -20,9 +20,10 @@
$data = $this->data(); $data = $this->data();
foreach ($data as $value) { foreach ($data as $value) {
$permission = Permission::create([ $permission = Permission::updateOrCreate([
'name' => $value['name'], 'name' => $value['name'],
'guard_name' => 'web', // or 'api 'guard_name' => 'web' // or 'api
], [
'permission_group_id' => $value['group'] 'permission_group_id' => $value['group']
]); ]);
@ -61,7 +62,7 @@
{ {
$actions = []; $actions = [];
// list of permission actions // list of permission actions
$crud = ['create', 'read', 'update', 'delete', 'authorize', 'report']; $crud = ['create', 'read', 'update', 'delete'];
foreach ($crud as $value) { foreach ($crud as $value) {
$actions[] = $name . '.' . $value; $actions[] = $name . '.' . $value;