Answer the question
In order to leave comments, you need to log in
How to get hasMany relationship in Eloquent with multiple tables?
I have tables with user_id fields.
Is it possible to somehow make a connection so that the selection goes through all these tables and as a result I have all the records from different tables with user_id=<given>?
UPD
$user->relatesRecords()->where()->get()
Answer the question
In order to leave comments, you need to log in
You can pull the necessary dependencies along with the user like this:
User::with(['some1', 'some2', 'some3'])->where('id', $yourId)->get()
There are not enough details, but it seems that combining using the with method and creating a query scope https://laravel.com/docs/5.3/eloquent#query-scopes should be fine for you , see the examples in the documentation.
UPD here is a similar example of what I said https://laracasts.com/discuss/channels/eloquent/mu...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question