Skip to content

Commit f464b72

Browse files
authored
Fixed entity management
1 parent fa95b1e commit f464b72

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/Http/Controllers/RolesController.php

+6-9
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,17 @@ public function edit($name) : View
4444
{
4545
$role = (new Role)->with('permissions')->find($name);
4646
$this->authorize('edit', $role);
47-
$actions = (new Action)->all();
48-
$entities = collect(array_keys(app('Illuminate\Contracts\Auth\Access\Gate')->policies()))
49-
->map(function ($entity) {
50-
return strtolower(collect(explode('\\', $entity))->last());
51-
})
52-
->filter(function ($entity) {
53-
return ! in_array($entity, ['permission', 'entity']);
54-
})
55-
->map(function ($entity) {
47+
collect(array_keys(app('Illuminate\Contracts\Auth\Access\Gate')->policies()))
48+
->each(function ($entity) {
49+
$entity = strtolower(collect(explode('\\', $entity))->last());
50+
5651
return (new Entity)
5752
->firstOrCreate([
5853
'name' => $entity,
5954
]);
6055
});
56+
$entities = (new Entity)->whereNotIn('name', ['permission', 'entity'])->get();
57+
$actions = (new Action)->all();
6158
$ownerships = (new Ownership)->all();
6259
$permissionMatrix = [];
6360

0 commit comments

Comments
 (0)