/** * 実行 * @param null $one * @return \Illuminate\Http\RedirectResponse */ public function postApply($one = null) { if (\Input::get('_return')) { return \Redirect::route('webmaster.category.form', ['id' => $one])->withInput(); } $request = \Input::only(['section_id', 'name', 'description']); try { // added if (is_null($one)) { $this->category->addCategory($request); // updated } else { $this->category->updateCategory($one, $request); } // session remove \Session::forget(self::SESSION_KEY); $this->view('webmaster.category.apply', ['id' => $one]); } catch (\Illuminate\Database\QueryException $e) { return \Redirect::route('webmaster.category.form', ['one' => $one])->withErrors(['name' => 'そのカテゴリーはすでに使用されています'])->withInput(); } }
/** * Update a existing category. * * @param Category $category * @param array $parametars * @return mixed */ public function updateCategory(Category $category, array $parametars) { return $this->repository->updateCategory($category, $parametars); }