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.
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.
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()