5

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?

Ben
  • 311
  • 1
  • 2
  • 12

1 Answers1

4

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
Sohel0415
  • 9,523
  • 21
  • 30
  • That @Sohel0415 makes good sense, thank you. Although I wonder if I lose anything from the Sentinel model by doing this? Is there a reason they didn't set it up like that by default? – Ben Jan 25 '18 at 16:27
  • if it solves your problem, then upvote it and accept it as it may help others later – Sohel0415 Jan 25 '18 at 16:28
  • I will, but any ideas if I lose anything by doing it this way? – Ben Jan 25 '18 at 16:30
  • As your data in your users table and its not going anywhere, then there is nothing to lose in my sense. Actually your functionality will remain same as you are extending eloquent user. – Sohel0415 Jan 25 '18 at 16:31
  • Thank you. I don't know why they don't do that by default then! – Ben Jan 25 '18 at 19:02
  • Solved my problem. Thanks – Christopher Kikoti May 05 '20 at 14:49