F
Filament5w 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
Alan5w 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
toeknee5w ago
Did you setup the policies correctly?
Alan
Alan5w 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
toeknee5w ago
Looks good, what laravel version are you on? You might need to register the policies
toeknee
toeknee5w 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
Alan5w ago
laravel 11 and filament v3.Implemented the Gate policy as in the documentation
No description
toeknee
toeknee5w ago
Test that the policy is being hit with a dd() on the view
Alan
Alan5w ago
No description
toeknee
toeknee5w 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
Alan5w ago
when dd() $user in UserPolicy roles are [] empty do we need to add anything additional .
No description
No description
No description
toeknee
toeknee5w ago
are you using multi-tenancy?
Alan
Alan5w 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
toeknee5w 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
Alan5w ago
was false
toeknee
toeknee5w ago
So the user isn't assigned to that permision within their roles.
Alan
Alan5w 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