当前位置: 首页>>代码示例>>PHP>>正文


PHP Menu::findOrFail方法代码示例

本文整理汇总了PHP中app\Menu::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Menu::findOrFail方法的具体用法?PHP Menu::findOrFail怎么用?PHP Menu::findOrFail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Menu的用法示例。


在下文中一共展示了Menu::findOrFail方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, Request $request)
 {
     //$this->validate($request, ['name' => 'required']); // Uncomment and modify if needed.
     $menu = Menu::findOrFail($id);
     $menu->update($request->all());
     return redirect('admin/menus')->with('success', Lang::get('message.success.update'));
 }
开发者ID:Nina23,项目名称:template,代码行数:13,代码来源:MenusController.php

示例2: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, Request $request)
 {
     //$this->validate($request, ['name' => 'required']); // Uncomment and modify if you need to validate any input.
     $menu = Menu::findOrFail($id);
     $menu->update($request->all());
     Session::flash('flash_message', 'Menu successfully updated!');
     return redirect('menu');
 }
开发者ID:Armen2004,项目名称:laravel,代码行数:14,代码来源:MenuController.php

示例3: update

 /**
  * Updates the current record in the database
  *
  * @param $id
  * @param MenuRequest $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function update($id, MenuRequest $request)
 {
     $inputs = $request->all();
     if ($request->get('is_main_course') === null) {
         $inputs['is_main_course'] = 0;
     }
     $menu = Menu::findOrFail($id);
     $menu->update($inputs);
     flash()->message('Successfully updated: ' . $menu->name, 'success');
     return redirect()->route('admin.menus.edit', [$menu->id]);
 }
开发者ID:jovvybersamin,项目名称:laravel-edronscateringservices,代码行数:18,代码来源:MenuController.php

示例4: handle

 /**
  * Execute the command.
  *
  * @return void
  */
 public function handle()
 {
     $slug = Slug::create(['name' => $this->request->slug, 'slug_attribute_id' => self::SLUG_ATTRIBUTE_MENU]);
     $this->request['slug_id'] = $slug->id;
     $menu = new Menu($this->request->all());
     $menu->generateOrder();
     if ($menu->location_id == 0) {
         $parent = Menu::findOrFail($menu->parent_id);
         $menu->location_id = $parent->location_id;
     }
     $menu->save();
     Activity::create(['text' => $this->auth->linkedName() . ' created new menu named ' . $menu->linkedName(), 'user_id' => $this->auth->id]);
     Session::flash('flash_message', 'Your menu has been created!');
 }
开发者ID:ronal2do,项目名称:Laravel-CMS,代码行数:19,代码来源:CreateMenuCommand.php

示例5: handle

 /**
  * Execute the command.
  *
  * @return void
  */
 public function handle()
 {
     $order = $this->order;
     for ($i = 0; $i < count($order); $i++) {
         $menu = Menu::findOrFail($order[$i]);
         $temp_order = $i + 1;
         if ($menu->order != $temp_order) {
             $menu->order = $temp_order;
             $menu->save();
         }
     }
     if (!$this->parent) {
         $parent_link = 'Base menu';
     } else {
         $parent_link = $this->parent->linkedName();
     }
     Activity::create(['text' => $this->auth->linkedName() . ' updated order for ' . $parent_link . "'s children menu list", 'user_id' => $this->auth->id]);
 }
开发者ID:ronal2do,项目名称:Laravel-CMS,代码行数:23,代码来源:UpdateMenuOrderCommand.php

示例6: ajaxDestroy

 public function ajaxDestroy(Request $request)
 {
     $validator = Validator::make($request->all(), ['menu_id' => 'required|min:1|exists:menus,id']);
     if ($validator->fails()) {
         return ['success' => false, 'message' => $validator->errors()->first('menu_id')];
     }
     $this->dispatch(new DestroyMenuCommand(Auth::user(), Menu::findOrFail($request->menu_id)));
     return ['success' => true, 'id' => $request->menu_id];
 }
开发者ID:ronal2do,项目名称:Laravel-CMS,代码行数:9,代码来源:MenuController.php

示例7: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(MenuUpdateRequest $request, $id)
 {
     $menu = Menu::findOrFail($id);
     foreach (array_keys(array_except($this->fields, ['menu'])) as $field) {
         $menu->{$field} = $request->get($field);
     }
     $menu->save();
     return redirect("/admin/menu/{$id}/edit")->withSuccess("Changes saved.");
 }
开发者ID:canwonson,项目名称:blog,代码行数:16,代码来源:MenuController.php

示例8: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $menu = Menu::findOrFail($id);
     $categories = DB::table('categories')->select('categories.id', 'categories.title', 'categories.level', DB::raw("(CASE categories.level \n                                      WHEN 0 THEN LPAD(categories.ordering,5,0)\n                                      WHEN 1 THEN (SELECT CONCAT(LPAD(m.ordering,5,0), '.' ,LPAD(categories.ordering,5,0)) FROM categories as m WHERE m.id=categories.parent_id)\n                                      WHEN 2 THEN (SELECT CONCAT((SELECT LPAD(super.ordering,5,0) FROM categories AS super WHERE super.id = m.parent_id), '.' , LPAD(m.ordering,5,0), '.' ,LPAD(categories.ordering,5,0)) FROM categories as m WHERE m.id=categories.parent_id)\n                                      END) AS Pos"))->where('status', 1)->whereNull('deleted_at')->orderBy('Pos')->get();
     return View('admin.menus.update_menu')->with(['menus' => Menu::where('level', '<', '2')->where('status', 1)->where('id', '<>', $id)->get(), 'categories' => $categories, 'menu' => $menu]);
 }
开发者ID:TEACHER-KEAK,项目名称:GAD,代码行数:12,代码来源:MenuController.php

示例9: sort

 /**
  * Sort the specified resource from storage.
  *
  * @return \Illuminate\Http\Response
  */
 public function sort()
 {
     $input = \Input::get('menuItem');
     $line = 1;
     foreach ($input as $id => $parent) {
         $menu = Menu::findOrFail($id);
         if ($parent == "null") {
             $menu->parent_id = NULL;
         } else {
             $menu->parent_id = $parent;
         }
         $menu->line = $line;
         $menu->save();
         $line++;
     }
     $this->rebuild();
     // slug making
     $menus = Menu::all();
     foreach ($menus as $menu) {
         $this->recursive_slug($menu->id);
         $menu->slug = $this->slug;
         $menu->eng_slug != '/home' ? $menu->eng_slug = '/eng' . $this->eng_slug : null;
         $menu->save();
         $this->slug = "";
         $this->eng_slug = "";
     }
     // anasayfa herzaman ilk sırada
     $home = Menu::where('slug', '/anasayfa')->first()->save(['line' => 0]);
     \Activity::log('Menü Sıralaması Değiştirildi');
 }
开发者ID:karpuzkan,项目名称:laravel,代码行数:35,代码来源:MenuController.php


注:本文中的app\Menu::findOrFail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。