Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel - Sentinel User is not the same as eloquent User

Tags:

I am using Laravel and Sentinel for my authentication.

Authentication works fine, I can log in using Sentinel and get back a User and I can see all of the User's fields.

However, I cannot access it's relationships (other than the Sentinel roles).

$user = Sentinel::findById($userId);
dd($user->telephones); // returns null

$user = App\User::find($userId);
dd($user->telephones); // displays a dump of the associated eloquent collection

Is there a way to retrieve the eloquent User from Sentinel so I can look at it's relationships?

like image 811
Ben Avatar asked Jan 25 '18 10:01

Ben


1 Answers

In your User model extend Sentinel EloquentUser.

class User extends EloquentUser

And in your catalyst sentinel config set user model like-

'users' => [
    'model' => 'App\User',
],

And don't forget to run-

php artisan config:clear
like image 136
Sohel0415 Avatar answered Sep 23 '22 13:09

Sohel0415