Skip to content

Commit

Permalink
now it takes the guard into account while updating or creating a role
Browse files Browse the repository at this point in the history
  • Loading branch information
bezhanSalleh committed May 21, 2023
1 parent b4ee172 commit 480ec2b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/Resources/RoleResource/Pages/CreateRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ protected function afterCreate(): void
{
$permissionModels = collect();
$this->permissions->each(function ($permission) use ($permissionModels) {
$permissionModels->push(Utils::getPermissionModel()::firstOrCreate(
$permissionModels->push(Utils::getPermissionModel()::firstOrCreate([
/** @phpstan-ignore-next-line */
['name' => $permission],
['guard_name' => $this->data['guard_name']]
));
'name' => $permission,
'guard_name' => $this->data['guard_name'],
]));
});

$this->record->syncPermissions($permissionModels);
Expand Down
8 changes: 4 additions & 4 deletions src/Resources/RoleResource/Pages/EditRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ protected function afterSave(): void
{
$permissionModels = collect();
$this->permissions->each(function ($permission) use ($permissionModels) {
$permissionModels->push(Utils::getPermissionModel()::firstOrCreate(
['name' => $permission],
['guard_name' => $this->data['guard_name']]
));
$permissionModels->push(Utils::getPermissionModel()::firstOrCreate([
'name' => $permission,
'guard_name' => $this->data['guard_name'],
]));
});

$this->record->syncPermissions($permissionModels);
Expand Down

0 comments on commit 480ec2b

Please sign in to comment.