diff --git a/config/filament-spatie-roles-permissions.php b/config/filament-spatie-roles-permissions.php index 6c17512..4479d0d 100644 --- a/config/filament-spatie-roles-permissions.php +++ b/config/filament-spatie-roles-permissions.php @@ -25,6 +25,22 @@ 'roles' => true, ], + /* + * Set as true to use simple modal resource. + */ + 'should_use_simple_modal_resource' => [ + 'permissions' => false, + 'roles' => false, + ], + + /* + * Set as true to remove empty state actions. + */ + 'should_remove_empty_state_actions' => [ + 'permissions' => false, + 'roles' => false, + ], + /** * Set to true to redirect to the resource index instead of the view */ diff --git a/src/Resources/PermissionResource.php b/src/Resources/PermissionResource.php index 75713f1..a73daa9 100644 --- a/src/Resources/PermissionResource.php +++ b/src/Resources/PermissionResource.php @@ -183,9 +183,12 @@ public static function table(Table $table): Table ->required(), ])->deselectRecordsAfterCompletion(), ]) - ->emptyStateActions([ - Tables\Actions\CreateAction::make(), - ]); + ->emptyStateActions( + config('filament-spatie-roles-permissions.should_remove_empty_state_actions.permissions') ? [] : + [ + Tables\Actions\CreateAction::make() + ] + ); } public static function getRelations(): array @@ -197,6 +200,12 @@ public static function getRelations(): array public static function getPages(): array { + if (config('filament-spatie-roles-permissions.should_use_simple_modal_resource.permissions')) { + return [ + 'index' => ListPermissions::route('/'), + ]; + } + return [ 'index' => ListPermissions::route('/'), 'create' => CreatePermission::route('/create'), diff --git a/src/Resources/RoleResource.php b/src/Resources/RoleResource.php index 1a354a5..aa277ec 100644 --- a/src/Resources/RoleResource.php +++ b/src/Resources/RoleResource.php @@ -156,9 +156,12 @@ public static function table(Table $table): Table Tables\Actions\DeleteBulkAction::make(), ]), ]) - ->emptyStateActions([ - Tables\Actions\CreateAction::make(), - ]); + ->emptyStateActions( + config('filament-spatie-roles-permissions.should_remove_empty_state_actions.roles') ? [] : + [ + Tables\Actions\CreateAction::make() + ] + ); } public static function getRelations(): array @@ -171,6 +174,12 @@ public static function getRelations(): array public static function getPages(): array { + if (config('filament-spatie-roles-permissions.should_use_simple_modal_resource.roles')) { + return [ + 'index' => ListRoles::route('/'), + ]; + } + return [ 'index' => ListRoles::route('/'), 'create' => CreateRole::route('/create'),