/**
* store
* 새로운 메뉴 생성을 처리하는 메소드
*
* @param MenuHandler $handler menu handler
*
* @return mixed
* @throws Exception
*/
public function store(MenuHandler $handler)
{
$desktopTheme = Input::get('theme_desktop');
$mobileTheme = Input::get('theme_mobile');
$rules = ['menuTitle' => 'required', 'theme_desktop' => 'required', 'theme_mobile' => 'required'];
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
Input::flash();
return Redirect::back()->with('alert', ['type' => 'danger', 'message' => $validator->messages()]);
}
XeDB::beginTransaction();
try {
$menu = $handler->create(['title' => Input::get('menuTitle'), 'description' => Input::get('menuDescription'), 'siteKey' => Input::get('siteKey')]);
$handler->setMenuTheme($menu, $desktopTheme, $mobileTheme);
$this->permissionRegisterGrant($menu->getKey(), $handler->getDefaultGrant());
} 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');
}