Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.17 KB | None | 0 0
  1. // Posts and Tags have the "many to many" relation.
  2.  
  3. $arrayOfTags = [1,2,5];
  4.  
  5. $posts = Post::whereHas('tags', function($q) {
  6. $q->whereIn('tags.id', $arrayOfTags);
  7. } )->get();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement