Return only values that have all the necesary relations

Viewed 16

Building Tag filter, and upon trying to filter out the data by tag IDs, I get all the values that have some of the tags sent, but I get those that have at least 1 of those tags, not all of them...How do I make it to get only the items that have all of the sent tags related to them?

return MealItem::with($withParam)->whereHas('MealTag', function($q) use($tags){
                    $q->whereIn('id', $tags);
                },'>=', count($tags))->has('MealIngredient')->get();
0 Answers
Related