Return only values that have all the necesary relations [duplicate] - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Saturday, September 10, 2022

Return only values that have all the necesary relations [duplicate]

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();


source https://stackoverflow.com/questions/73666586/return-only-values-that-have-all-the-necesary-relations

No comments:

Post a Comment