Filament Panel - how hide / show items based on user privileges?
Hi in my app we have 2 classes of user - internal_researcher & external_researcher. For the latter, we want to show few options in the menu (which I have done by adding into the relevant resources code similar to this)
The dashboard has some widgets and another panel and I am trying to understand / locate documentation to describe how to conditionally show these based on user some condition.
Would appreciate a pointer to relevant docs.
Thanks in advance,
j
6 Replies
You should use canAccess
You can add this method to your widget class:
I wouldn't use canView since this is for individual model records, canAccess is the first instance checking if they can access the resource.
Does that work on widgets?
It's better to use Policies or
canAccess()
for pages, because the pages will still be accessible.
The second part was about Widgets not Pages.I meant to say "Thanks all for your guidance" - I don't like to leave responses un-acknowledged!