Skip to content

Commit 8a6b3ad

Browse files
committed
Fixed creation of permission if entity is missing.
1 parent eb7b3db commit 8a6b3ad

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Http/Middleware/ParseCustomPolicyActions.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,14 @@ protected function registerCustomPolicyActions(): void
6060
->first();
6161

6262
if (! $permission) {
63+
$entityClass = config("genealabs-laravel-governor.models.entity");
6364
$permissionClass = config("genealabs-laravel-governor.models.permission");
65+
$entity = (new $entityClass)->firstOrCreate([
66+
"name" => $action->entity,
67+
]);
6468
(new $permissionClass)->firstOrCreate([
6569
"role_name" => "SuperAdmin",
66-
"entity_name" => $action->entity,
70+
"entity_name" => $entity,
6771
"action_name" => $action->name,
6872
"ownership_name" => "any",
6973
]);

0 commit comments

Comments
 (0)