Answer the question
In order to leave comments, you need to log in
How to filter out belongstomany?
There are tables
places
-id
comforts
-id
comfort_place
-id
-comfort_id
-place_id
Is it possible in Place::where to filter data by id array?
you need to output place, in which there is a combination of both comfort_id = 1, and comfort_id = 2, and comfort_id = 3
Answer the question
In order to leave comments, you need to log in
Place::whereHas('comforts', function($q){
$q->whereIn('id', [1, 2, 3]);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question