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
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.
Did you setup the policies correctly?
I used the
shield:generate and shield:publish commands, which automatically generated the necessary files. I did not make any modifications to these files.
Looks good, what laravel version are you on? You might need to register the policies
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-shieldlaravel 11 and filament v3.Implemented the Gate policy as in the documentation
Test that the policy is being hit with a dd() on the view
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
when dd() $user in UserPolicy roles are [] empty do we need to add anything additional .
are you using multi-tenancy?
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 .
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()
was false
So the user isn't assigned to that permision within their roles.
i now wiped all db and now i got roles page for super admin, Added new roles and checked works fine