/** * Edit category form * * @param Category $category * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function edit(Category $category) { $fields = Field::lists('name', 'id')->toArray(); $categories = ['' => 'Родительская категория'] + Category::where('id', '!=', $category->id)->whereNotIn('id', $category->children()->lists('id')->toArray())->lists('name', 'id')->toArray(); return view('backend.shop.category.edit', compact('category', 'categories', 'fields')); }