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);
}
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
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community