Spatie Roles Permissions

How can I make a resource only accessible for a specific role?
5 Replies
GeRaged | Niklas
GeRaged | NiklasOP13mo ago
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 Harrin13mo ago
isnt it viewAny()? and a policy?
christmex
christmex13mo 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
slooffmaster13mo ago
I can only agree; great plugin!
Want results from more Discord servers?
Add your server