public function liveSearch(Request $request) { $posts = Post::whereRaw("MATCH(title,location,content) AGAINST(? IN BOOLEAN MODE)", array($request->string))->take(5)->get(); if ($posts->isEmpty()) { return response()->json(['count' => 0]); } return response()->json(['count' => 1, 'posts' => $posts]); }