Search code examples
phplaravelsentinel

Laravel - Sentinel User is not the same as eloquent User


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?


Solution

  • 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