/** * 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); } }
/** * Show the form for editing the specified resource. * * @param int $id * * @return Response */ public function edit(Category $category) { $codes = $category->codes; $selectedFieldsId = array_reverse($category->fields()->lists('fields.id')->toArray()); $fields = Field::whereNotIn('id', $selectedFieldsId)->get(); $parent_id = $category->parent_id; return view_backend('category.edit', compact('category', 'codes', 'fields', 'parent_id')); }