Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Lloric Mayuga Garcia <[email protected]>
  • Loading branch information
lloricode committed Aug 25, 2024
1 parent 892eaf4 commit da0c667
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
11 changes: 8 additions & 3 deletions src/Database/Seeders/DefaultPermissionSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,14 @@ private static function getPermissionsFromPages(): array
/** @return array<int, string> */
protected function getCustomPermissionNames(): array
{
return collect(PermissionConfig::customPermissionsNames())
->map(fn (string $custom) => FilamentPermissionGenerateName::getCustomPermissionName($custom))
->prepend(PermissionType::customs->value)
$customs = collect(PermissionConfig::customPermissionsNames())
->map(fn (string $custom) => FilamentPermissionGenerateName::getCustomPermissionName($custom));

if ($customs->isEmpty()) {
return [];
}

return $customs->prepend(PermissionType::customs->value)
->values()
->sort()
->toArray();
Expand Down
20 changes: 8 additions & 12 deletions src/Resources/RoleResource/Schema/PermissionSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,43 +132,39 @@ function (Get $get): array {
]),
Forms\Components\Tabs\Tab::make(trans('Panels'))
->schema(function () {
$return = [];

foreach (PermissionCollection::groupByTypeThenParent(self::$guardName)[PermissionType::panels->value] ?? [] as $parentPermission => $permissionsDatas) {
$return[] = self::abilities($permissionsDatas, $parentPermission);
return [self::abilities($permissionsDatas, $parentPermission)];
}

return $return;
return [];
}),
Forms\Components\Tabs\Tab::make(trans('Pages'))
->schema(function () {
$return = [];

foreach (PermissionCollection::groupByTypeThenParent(self::$guardName)[PermissionType::pages->value] ?? [] as $parentPermission => $permissionsDatas) {
$return[] = self::abilities($permissionsDatas, $parentPermission);
return [self::abilities($permissionsDatas, $parentPermission)];
}

return $return;
return [];
}),
Forms\Components\Tabs\Tab::make(trans('Widgets'))
->schema(function () {
$return = [];

foreach (PermissionCollection::groupByTypeThenParent(self::$guardName)[PermissionType::widgets->value] ?? [] as $parentPermission => $permissionsDatas) {
$return[] = self::abilities($permissionsDatas, $parentPermission);
return [self::abilities($permissionsDatas, $parentPermission)];
}

return $return;
return [];
}),
Forms\Components\Tabs\Tab::make(trans('Custom permissions'))
->schema(function () {
$return = [];

foreach (PermissionCollection::groupByTypeThenParent(self::$guardName)[PermissionType::customs->value] ?? [] as $parentPermission => $permissionsDatas) {
$return[] = self::abilities($permissionsDatas, $parentPermission);
return [self::abilities($permissionsDatas, $parentPermission)];
}

return $return;
return [];
}),
]),

Expand Down

0 comments on commit da0c667

Please sign in to comment.