Reputation: 969
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?
Upvotes: 1
Views: 178
Reputation: 7083
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);
}
Upvotes: 1