phplaravelentrust

@role directive for multiple roles in Zizaco/entrust laravel package


I am using Zizaco/entrust laravel package and now I want to use @role directive in blade template to show an item only to some defined roles like this :

@role('developer,administrator')
<li><a href="/admin/permission">Permissions</a></li>
@endrole

But this does not work. is it possible ?


Solution

  • I read some code and looks like code below will work for You:

    @role(['developer','administrator'])
    <li><a href="/admin/permission">Permissions</a></li>
    @endrole
    

    Because You are sending array to this function: https://github.com/Zizaco/entrust/blob/master/src/Entrust/Traits/EntrustUserTrait.php#L90