/** * @param $input * @return mixed * @throws MenuBuilderMenuItemNotFoundException */ public function getMenuItem($input) { // If we where given a MenuItem return it. if ($input instanceof Menu) { return $input; } // Fix #21: PostgreSQL throws an QueryException when we search a text value in a // field of numerical type. try { // Try to find the root object by it's ID $menuItem = $this->menuRepository->find($input); if ($menuItem instanceof Menu) { return $menuItem; } } catch (QueryException $ex) { } try { // Try to find the root object by it's name $menuItem = $this->menuRepository->findBy('name', $input); if ($menuItem instanceof Menu) { return $menuItem; } } catch (QueryException $ex) { } // Could not find the requested menu item, throwing an exception. throw new MenuBuilderMenuItemNotFoundException("Menu item [" . $input . "] not found."); }
/** * 显示更新表单. * * @param $id * * @return mixed */ public function getUpdate($id) { $menuData = $this->menuRepository->find($id); $topMenuList = $this->menuService->getTopMenu(); return user_view('menu.create', compact('menuData', 'topMenuList')); }