Implementing Role-Based Access Control for Custom Pages on Filament
Hello! How are you? I'm trying to define a specific middleware to access a custom page on Filament. How could I make it so that only, for example, those with the 'teacher' role can access a custom page? Is there a function I can put in page.php?
5 Replies
I use policies for resources...
My page for example
Solution
public static function canAccess(): bool
{
return auth()->user()->canManageSettings();
}
tanks
Sorry
But
How do I make it in canAcess for it to go through a middleware coming from App\Http\Middleware?
Have a look at the code for how #bezhansalleh-shield does it. It has page level authorization.
Don’t be afraid to source dive. 😁