SketchBookkeeper
3/14/2019 - 7:21 PM

Get posts by tags, pivot

// Posts and Tags have the "many to many" relation.

$arrayOfTags = [1,2,5];

$posts = Post::whereHas('tags', function($q) { 
    $q->whereIn('tags.id', $arrayOfTags);
} )->get();