I am using https://filamentphp.com/plugins/bezhansalleh-shield for roles and permissions.
I have 3 panels (admin, home and app)
In the Roles table, it shows 114 permissions from all panels and resources
When I edit super_admin role on the admin panel, it only shows 54 permissions from the admin panel resources. It does not show the permissions for other panels.
I need to see all permissions on the Roles table for a centralized Roles and permissions management
UPDATE:
I implemented some changes based on the suggestion below and now no permissions are being shown
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Grid::make()
->schema([
Forms\Components\Section::make()
->schema([
Forms\Components\TextInput::make('name')
->label(__('filament-shield::filament-shield.field.name'))
->unique(
ignoreRecord: true,
modifyRuleUsing: fn (Unique $rule) => ! Utils::isTenancyEnabled() ? $rule : $rule->where(Utils::getTenantModelForeignKey(), Filament::getTenant()?->id)
)
->required()
->maxLength(255),
Forms\Components\TextInput::make('guard_name')
->label(__('filament-shield::filament-shield.field.guard_name'))
->default(Utils::getFilamentAuthGuard())
->nullable()
->maxLength(255),
Forms\Components\Select::make(config('permission.column_names.team_foreign_key'))
->label(__('filament-shield::filament-shield.field.team'))
->placeholder(__('filament-shield::filament-shield.field.team.placeholder'))
->default([Filament::getTenant()?->id])
->options(fn (): Arrayable => Utils::getTenantModel() ? Utils::getTenantModel()::pluck('name', 'id') : collect())
->hidden(fn (): bool => ! (static::shield()->isCentralApp() && Utils::isTenancyEnabled()))
->dehydrated(fn (): bool => ! (static::shield()->isCentralApp() && Utils::isTenancyEnabled())),
ShieldSelectAllToggle::make('select_all')
->onIcon('heroicon-s-shield-check')
->offIcon('heroicon-s-shield-exclamation')
->label(__('filament-shield::filament-shield.field.select_all.name'))
->helperText(fn (): HtmlString => new HtmlString(__('filament-shield::filament-shield.field.select_all.message')))
->dehydrated(fn (bool $state): bool => $state),
])
->columns([
'sm' => 2,
'lg' => 3,
]),
]),
Forms\Components\Section::make('Permissions')
->schema([
Tabs::make('Tabs')
->tabs([
self::getPermissionsTab('admin'),
self::getPermissionsTab('home'),
self::getPermissionsTab('MOJO'),
]),
]),
]);
}
protected static function getPermissionsTab(string $panel): Tab
{
$originalPanel = Filament::getCurrentPanel();
Filament::setCurrentPanel(Filament::getPanel($panel));
$permissions = Permission::where('guard_name', $panel)->pluck('name', 'name')->toArray();
Filament::setCurrentPanel($originalPanel);
return Tab::make(Str::headline($panel))
->schema([
CheckboxList::make('permissions')
->label('Permissions from ' . ucfirst($panel))
->options(array_combine($permissions, $permissions))
->columns(2),
]);
}
Apparently, there are options in the filament-shield config that solves the problem. Set discoveries to true depending on your needs.
'discovery' => [
'discover_all_resources' => true,
'discover_all_widgets' => true,
'discover_all_pages' => true,
],