I'm trying to do a search on a belongs to many relationship.
I have links, and link tags, a link can have many link tags.
So what I'm trying to do is search for two tags, but I only want it to return links which have BOTH tags. So far I have this:
$links = Link::whereHas('linktags', function($q) use($query, $where) {
$q->whereIn('name', $query);
})->with('linktags')->get();
This does search the relationship, and returns a result, but it matches ANY of the tags, not BOTH of them.
I've looked at the documentation but I cannot find a way of doing this. Any ideas?