Spatie Roles Permissions

How can I make a resource only accessible for a specific role?
5 Replies
GeRaged | Niklas
I tried this and added an debug message to it, but on visit, there is no debug message.
public static function canView(Model $record): bool
{
return auth()->user()->hasRole('Admin');
}
public static function canView(Model $record): bool
{
return auth()->user()->hasRole('Admin');
}
Dan Harrin
Dan Harrin8mo ago
isnt it viewAny()? and a policy?
christmex
christmex8mo ago
@GeRaged | Niklas maybe u can also try shield plugin https://filamentphp.com/plugins/bezhansalleh-shield
Filament
Shield by Bezhan Salleh - Filament
The easiest and most intuitive way to add access management to your Filament Panel's Resources, Pages & Widgets through spatie/laravel-permission.
slooffmaster
slooffmaster8mo ago
I can only agree; great plugin!