Instead of an isAdmin method, how about an hasRole method?
Auth::user()->hasRole(['admin', 'moderator' ])
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, I created roles and i want to assign pages based on its roles ie. admin can view all pages and customer can view 4 pages, but in my system there can be more roles in future so i don't want to code every time when i create new roles.
I made a page where i can select role and assign pages to that roles, but i am getting problem to achieve this because i don't know how to restrict other roles to access this page.
-- the original way is like this
@if ( Auth::check() && Auth::user()->isAdmin() )
...
@endif
-- but my roles can be change every time and i don't want to code again and again
i need your help to achieve this
Please or to participate in this conversation.