/** * Display the specified resource. * * @param int $id * * @return Response */ public function searchFields(Category $category) { if (\Request::ajax() && $category->has('fields')) { return $category->fields()->whereIsInSearch('1')->with(['search', 'select' => function ($query) { $query->orderBy('position', 'asc'); }])->get(); } else { abort(404); } }