/** * updateItem * 메뉴 아이템 수정 처리 메소드 * * @param MenuHandler $handler menu handler * @param string $menuId menu id * @param string $itemId item id * * @return RedirectResponse * @throws Exception */ public function updateItem(MenuHandler $handler, $menuId, $itemId) { XeDB::beginTransaction(); try { $inputs = Input::except(['_token', 'theme_desktop', 'theme_mobile']); $item = $handler->getItem($itemId); $menu = $item->menu; if ($menu->getKey() !== $menuId) { throw new InvalidArgumentHttpException(400); } $parentThemeMode = Input::get('parentTheme', false); if ($parentThemeMode === false) { $desktopTheme = Input::get('theme_desktop'); $mobileTheme = Input::get('theme_mobile'); } else { $desktopTheme = null; $mobileTheme = null; } list($itemInput, $menuTypeInput) = $this->inputClassify($inputs); $item->fill(['title' => $itemInput['itemTitle'], 'url' => $itemInput['itemUrl'], 'description' => $itemInput['itemDescription'], 'target' => $itemInput['itemTarget'], 'ordering' => $itemInput['itemOrdering'], 'activated' => array_get($itemInput, 'itemActivated', '0')]); // link image 등록 $this->registerItemImage($item, 'basicImage'); $this->registerItemImage($item, 'hoverImage'); $this->registerItemImage($item, 'selectedImage'); $this->registerItemImage($item, 'mBasicImage'); $this->registerItemImage($item, 'mHoverImage'); $this->registerItemImage($item, 'mSelectedImage'); $handler->putItem($item, $menuTypeInput); $handler->updateMenuItemTheme($item, $desktopTheme, $mobileTheme); } catch (Exception $e) { XeDB::rollback(); Input::flash(); return Redirect::back()->with('alert', ['type' => 'danger', 'message' => $e->getMessage()]); } XeDB::commit(); return Redirect::route('settings.menu.index'); }