How can I know what role a specific user has if I am using Entrust in laravel?

0

I'm using the Entrust package to manage roles in laravel and I need to know how I can once all the roles are created and the users and the relationships between them as if I have a user saved in a variable knowing the role that corresponds to it.

    
asked by Luis Dariel Valenciano 21.03.2018 в 18:26
source

1 answer

1

If you only have one role for each user

You can achieve it in the following way

$usuario->roles()->first()->name

If you will have more than one role per user, you will have to do so

$usuario->roles()->get()
    
answered by 21.03.2018 / 18:29
source