Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

So instead of whereIn just break the array of tags out and do a where for each.

foreach ($tags as $tagId) {

$q->where('tags.id', $tagId);
}
0

Oh sorry I misunderstood your question. Ignore my answer. The problem is harder than it seems. I think you would have to do some kind of aggregation because you want to know where posts belongs to both tags of type 1 and 2

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.