Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mehrdad70's avatar

User access level when editing information spatie laravel permission

Hi everyone I have designed a system that the user, when he wants to edit his information, Specify your access level In the edit form I have called the roles like this

$roles = Role::all() 

But in this case, the user can admin himself

How can I specify when calling roles what roles are not displayed to the user that are not selectable, for example Admin Roles - Managing Comments - Managing User Permissions

0 likes
1 reply
CorvS's avatar

Not sure I understand you correctly, but if you want to get only certain roles you can remove the ones you don't want using whereNotIn() for example.

Role::whereNotIn('name', ['admin', 'whatever'])->get();

Please or to participate in this conversation.