/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(CategoryRequest $request, $id) { try { $this->category->update($id, $request->only('description', 'symbol')); return redirect()->back(); } catch (Exception $e) { return redirect()->back()->withInput()->with('error', 'Không thể thao tác với '); } }
/** * Create new Category * * @param CategoryRequest $request Category request input validation * @return View */ public function store(CategoryRequest $request) { $input = $request->only('name', 'slug'); // Create new category with validated input $newCategory = Category::create($input); // If parent id is set find wanted category and make it parent of new category $parentId = $request->input('parent_id'); if ($parentId != "") { $parentCategory = Category::findOrFail($parentId); $newCategory->makeChildOf($parentCategory); } return redirect(route('AdminCategoryIndex')); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(CategoryRequest $request, $id) { (new Category())->editRow($request->only('name', 'menu_name', 'desc', 'visibility', 'parent_id'), $id); flash()->overlay("Category edited"); return redirect()->to('/category'); }
/** * Display the specified resource. * * @param CategoryRequest $request * @param $categoryId * @return \Illuminate\Http\Response */ public function show(CategoryRequest $request, $categoryId) { $input = $request->only(['with']); $category = (new Show($categoryId, $input))->run(); return $this->response->ok($category); }