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

gman01's avatar

Shinobi check for multiple roles

Hi,

Don't suppose anyone has an idea if its possible to check for multiple roles using this package?

     @role('admin')
                                I am an Admin/advisor User
                            @else
                            @endrole

Tried below but it throws an error.

@role('admin|advisor', 'all') // @if(Auth::check() && Auth::user()->is('admin|moderator', 'all'))
    // user is admin and also moderator
@else
    // something else
@endrole
0 likes
3 replies
gman01's avatar

Hey thanks for the reply.

I am using

https://github.com/caffeinated/shinobi

I've tried various ways, it does say you can add multi roles to a user, but no real documentation i can find to do it. I get a parse error on various things i try.

Braunson's avatar

@gman01 After looking at the actual code of that package, it doesn't seem to be able to support multiple roles. The blade syntax is registered here and shows it uses Shinobi::is(string), taking a look at that function here it expects a string always.

So you have a few options:

  1. Fork the repo, edit the is() function to support an array and put in a pull request
  2. Extend the Shinobi package to create a new function i.e. isRules(array())
  3. Create your own custom Blade directive that makes use of the Shinobi::is() function and you loop through the array provided.

Hope this gives you some more insight! :)

1 like

Please or to participate in this conversation.