F
Filament2mo ago
Alan

Using shield plugin but roles and permission page not found

I recently completed my project without the shield plugin. Now, I want to add roles and permissions. I've followed the documentation, but the roles pages aren't appearing for my super admin user.
17 Replies
Alan
AlanOP2mo ago
In a new project,the steps outlined in the documentation worked as expected, allowing me to successfully implement roles and permissions. However, when I tried to apply the same process to an existing project, I encountered an issue. I was unable to locate the roles page, even though I followed the same steps.
toeknee
toeknee2mo ago
Did you setup the policies correctly?
Alan
AlanOP2mo ago
I used the shield:generate and shield:publish commands, which automatically generated the necessary files. I did not make any modifications to these files.
No description
toeknee
toeknee2mo ago
Looks good, what laravel version are you on? You might need to register the policies
toeknee
toeknee2mo ago
GitHub
GitHub - bezhanSalleh/filament-shield: The easiest and most intuiti...
The easiest and most intuitive way to add access management to your Filament Admin Resources, Pages & Widgets through spatie/laravel-permission - bezhanSalleh/filament-shield
Alan
AlanOP2mo ago
laravel 11 and filament v3.Implemented the Gate policy as in the documentation
No description
toeknee
toeknee2mo ago
Test that the policy is being hit with a dd() on the view
Alan
AlanOP2mo ago
No description
toeknee
toeknee2mo ago
So test your conditions, and work out what's not being hit. I suspect you haven't setup a super admin function as per the spatie permissions docs
Alan
AlanOP2mo ago
when dd() $user in UserPolicy roles are [] empty do we need to add anything additional .
No description
No description
No description
toeknee
toeknee2mo ago
are you using multi-tenancy?
Alan
AlanOP2mo ago
i am using one panel only ,The project has multiple roles and data is different for each roles in some pages & some features are not there for some .
No description
toeknee
toeknee2mo ago
So doing a dd($user->can('view_any_user')); What does it return? If you view the permissions do you have view_any_user assigned? I also have a super admin function on my models which does $user->can('view_any_user') || $user->isSuperAdmin()
Alan
AlanOP2mo ago
was false
toeknee
toeknee2mo ago
So the user isn't assigned to that permision within their roles.
Alan
AlanOP2mo ago
i now wiped all db and now i got roles page for super admin, Added new roles and checked works fine
Want results from more Discord servers?
Add your server