Exemplo n.º 1
0
 public function tagSearch(Request $request)
 {
     $posts = Post::with('tags')->whereRaw("MATCH(title,location,content) AGAINST(? IN BOOLEAN MODE)", array($request->string))->take(20)->get();
     $tags = [];
     foreach ($posts as $post) {
         foreach ($post->tags as $tag) {
             $tags[] = $tag->name;
         }
     }
     $tags = array_unique($tags);
     return $tags;
 }