Skip to content

Commit

Permalink
Fixed creation of permission if entity is missing.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebronner committed Jun 9, 2022
1 parent eb7b3db commit 8a6b3ad
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Http/Middleware/ParseCustomPolicyActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ protected function registerCustomPolicyActions(): void
->first();

if (! $permission) {
$entityClass = config("genealabs-laravel-governor.models.entity");
$permissionClass = config("genealabs-laravel-governor.models.permission");
$entity = (new $entityClass)->firstOrCreate([
"name" => $action->entity,
]);
(new $permissionClass)->firstOrCreate([
"role_name" => "SuperAdmin",
"entity_name" => $action->entity,
"entity_name" => $entity,
"action_name" => $action->name,
"ownership_name" => "any",
]);
Expand Down

0 comments on commit 8a6b3ad

Please sign in to comment.