1

To get all the user informations in laravel 5.2 I use the Sentinel user system.

I can recive with $request->user() all the informations from the 'users' table. But i want get also every row from the 'messages' table.

I create a relation between 'users'.'ID' and 'messages'.'UID' but in Laravel the $request->user() content is still the same.

What do i need to modify to get all relation columns?

Laerte
  • 7,013
  • 3
  • 32
  • 50
Philipp Nies
  • 945
  • 4
  • 20
  • 38

1 Answers1

1

To eager load the relations you can use the following method:

$user = $request->user();
$user->load('messages');

For that, in User Model, you need to define the relationship:

public function messages()
{
    return $this->hasMany(Message::class);
}
Laerte
  • 7,013
  • 3
  • 32
  • 50