Answer the question
In order to leave comments, you need to log in
How to access relationships from another table in Laravel?
Hello, please help. There is such structure of tables.
On the page, I display data from the residents table. How to display the list of roles from the roles table in the same table?
The keys in the tables are created, the links in the models are registered.
Thank you!
Answer the question
In order to leave comments, you need to log in
In general, we managed to solve the problem. If anyone is interested:
in the controller:
$residents = Resident::with('user.roles')->paginate(25);
@foreach($resident->user->roles as $role)
{{$role->title}}
@endforeach
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question