Policy to allow admins to edit models in the admin panel
I am using the following code inside the policy class for the Duel model to prevent users from editing the model unless they are the opponent. However I want admins to be able to edit the model inside the filament panel.
After debugging my code I get the following output:
I noticed
Filament::auth()->check()
is always returning true, even if the admin panel isn't being accessed.
I even tried this variation:
The issue if the filament check code always return false and admins can't edit the model.3 Replies
You are over complicating it I think? Try removing the auth->check from the if and simply return true if hasRole and routeIs?
For readability maybe change your other return to be wrapped in an if and return true, and add a return false at the end?
Nope that didn't work.
Log:
route would be:
filament.admin.resources.models.edit
I believe....
Log each condition you check