dimanche 31 mars 2019

How to get all user roles in Laravel?

I use the following article to create user roles in Laravel.

My problem is, how to get all user roles after authorization?

I tried to get roles like this:

Auth::user()->roles()

Because User model has method roles().

But it does not work.

I suppose I need to get auth user id, then to get user model:

$user = User::where('id', Auth::user()->id)->get();

And then possible I can get access to roles:

$user->roles();



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire