Laravel permissions
I'm looking for the best way to manage the super admin role.
Currently in my User resource I have this :
So a user who can modify roles can assign super_admin to everyone.
how would you make it so that only a super_admin sees the super_admin role?
Maybe you should disable it altogether?
thanks π
5 Replies
Probably something like this:
Am doing it with checking the user id 1
So only user 1 can add/delete super admins
Other Super admins can't add or delete other super admins
You can certainly do what you need, just be aware that basing it on a user id will create problems down the road if that user ever gets deleted for whatever reason.
You can write a custom rule to check that
Like:
That'll be a total nightmare to maintain in the future.
Take 3 minutes to make a migrate to add a column, update your mode, and write the function and the test.
Future you will be very grateful.