App\Http\Controllers\MenuController::update PHP Method

update() public method

update
public update ( MenuHandler $handler, string $menuId ) : Illuminate\Http\RedirectResponse
$handler Xpressengine\Menu\MenuHandler menu handler
$menuId string to update menu entity object id
return Illuminate\Http\RedirectResponse
    public function update(MenuHandler $handler, $menuId)
    {
        $menu = $handler->get($menuId);
        $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->title = Input::get('menuTitle');
            $menu->description = Input::get('menuDescription');
            $handler->put($menu);
            $handler->updateMenuTheme($menu, $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');
    }