canEdit() (etc) on Filament resources
Hi all, I think I am being dense but I cannot find any documentation in Filament v3 around the canEdit, canDelete, etc. methods on a filament resource within a dashboard
A typical location for what I am talking about would be App/Filament/Admin/Resources/SpecificResource.php
Can anyone help point me in the right direction?
From testing, it seems if I have something defined here it over-rides the laravel policies for that same model. It also seems to only impact the model within the Filament panel, which makes sense.
I am trying to find the documentation to confirm this and also see if there is anything else I should consider.
Solution:Jump to solution
also see if there is anything else I should consider.Try to stick to policies as much as you can. Is there a reason you need to overwrite the behaviour in Filament?...
3 Replies
I don't think we have that documented. But you can probably just have a look at the definition of those methods.
From testing, it seems if I have something defined here it over-rides the laravel policies for that same model. It also seems to only impact the model within the Filament panel, which makes sense.Seems about right. The default method should probably just call the policy.
Solution
also see if there is anything else I should consider.Try to stick to policies as much as you can. Is there a reason you need to overwrite the behaviour in Filament?
Ok, noted.
I purchased a boilerplate that uses Filament and it had used these in some of the included resources, so I had assumed it was some sort of "typical" filament-approach that was common. I'll stick to policies, thank you Dennis!