當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。