Answer the question
In order to leave comments, you need to log in
How to compose a Laravel ORM query?
Good day.
There are 2 tables, one with a list of establishments, the other with the relationship of establishments to features.
It is necessary to choose establishments with the indicated features.
Institutions - institutions
id | good | ... | ... |
Relationship table - attitudes
feature_id | institution_id
$attitudes = [1, 2, 3];
$institutions = Institutions::where('good', 1);
$institutions = $institutions->whereHas('attitudes', function($query) use ($attitudes) {
$query->whereIn('feature_id', $attitudes);
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question