當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Category::findOrFail方法代碼示例

本文整理匯總了PHP中app\Category::findOrFail方法的典型用法代碼示例。如果您正苦於以下問題:PHP Category::findOrFail方法的具體用法?PHP Category::findOrFail怎麽用?PHP Category::findOrFail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Category的用法示例。


在下文中一共展示了Category::findOrFail方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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 you need to validate any input.
     $category = Category::findOrFail($id);
     $category->update($request->all());
     return redirect('category');
 }
開發者ID:abhatia2107,項目名稱:cat,代碼行數:13,代碼來源:CategoryController.php

示例2: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  *
  * @return Response
  */
 public function update($id, Request $request)
 {
     $category = Category::findOrFail($id);
     $category->update($request->all());
     Session::flash('flash_message', 'Category updated!');
     return redirect('admin/category');
 }
開發者ID:ercancavusoglu,項目名稱:CRUD-Ecommerce,代碼行數:14,代碼來源:CategoryController.php

示例3: update

 /**
  * Update the specified resource in storage.
  *
  * @param int $id
  *
  * @return Response
  */
 public function update(CategoryRequest $request, $id)
 {
     $category = Category::findOrFail($id);
     $category->update($request->all());
     \Cache::tags('categories')->flush();
     return redirect('admin/categories/index');
 }
開發者ID:kpaxer,項目名稱:laravel-blog,代碼行數:14,代碼來源:CategoriesController.php

示例4: show

 /**
  * Display the products of the specified category.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $category = Category::findOrFail($id);
     $categoryIdNav = $category->id;
     $products = $category->products()->latest()->available()->paginate(12);
     return view('category.show', compact('products', 'categoryIdNav'));
 }
開發者ID:foadk,項目名稱:online-store,代碼行數:13,代碼來源:CategoryController.php

示例5: update

 public function update(UpdateCategoryRequest $request, $id)
 {
     $category = Category::findOrFail($id);
     $category->update($request->all());
     session()->flash('flash_message', message('user_successfully_updated_category'));
     return redirect('/categories/manage');
 }
開發者ID:brslv,項目名稱:favdit,代碼行數:7,代碼來源:CategoriesController.php

示例6: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(CategoryRequest $request, $id)
 {
     $category = Category::findOrFail($id);
     $category->update($request->all());
     flash('Category has been updated');
     return Redirect::back();
 }
開發者ID:jentleyow,項目名稱:megadeal,代碼行數:14,代碼來源:CategoriesController.php

示例7: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     // bind article
     $router->model('article', 'App\\Article');
     $router->bind('admin.article', function ($id) {
         return \App\Article::findOrFail($id);
     });
     // bind category
     $router->model('category', 'App\\Category');
     $router->bind('admin.category', function ($id) {
         return \App\Category::findOrFail($id);
     });
     // bind language
     $router->model('language', 'App\\Language');
     $router->bind('admin.language', function ($id) {
         return \App\Language::findOrFail($id);
     });
     // bind language
     $router->model('page', 'App\\Page');
     $router->bind('admin.page', function ($id) {
         return \App\Page::findOrFail($id);
     });
     // bind setting
     $router->model('setting', 'App\\Setting');
     $router->bind('admin.setting', function ($id) {
         return \App\Setting::findOrFail($id);
     });
     // bind user
     $router->model('user', 'App\\User');
     $router->bind('admin.user', function ($id) {
         return \App\User::findOrFail($id);
     });
     parent::boot($router);
 }
開發者ID:abada,項目名稱:laravel-5-simple-cms,代碼行數:40,代碼來源:RouteServiceProvider.php

示例8: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(CategoryRequest $request)
 {
     $category = Category::findOrFail($request->get('id'));
     $category->name = $request->get('name');
     $category->save();
     return \Redirect::route('index-category')->with('message', 'Record has been Saved');
 }
開發者ID:alauddin1987,項目名稱:Laravel-Survey-System,代碼行數:14,代碼來源:CategoryController.php

示例9: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $category = Category::findOrFail($id);
     $category->delete();
     flash()->success('Category Deleted!');
     return redirect()->route('categories.index');
 }
開發者ID:laravelista,項目名稱:kyle,代碼行數:13,代碼來源:CategoryController.php

示例10: update

 /**
  * Update the specified category in storage.
  * @param UpdateCategoryRequest|Request $request
  *
  * @param  int  $id
  */
 public function update($id, UpdateCategoryRequest $request)
 {
     $category = Category::findOrFail($id);
     $request = $this->saveFiles($request);
     $category->update($request->all());
     return redirect()->route('admin.category.index');
 }
開發者ID:AmirHome,項目名稱:CMS_20160115,代碼行數:13,代碼來源:CategoryController.php

示例11: sort

 public function sort($id, Request $request)
 {
     $order = $request->order;
     $category = Category::findOrFail($id);
     $products = Product::where('category_id', '=', $id);
     switch ($order) {
         case "1":
             $products = $products->orderByName()->get();
             break;
         case "2":
             $products = $products->orderByName("DESC")->get();
             break;
         case "3":
             $products = $products->orderByPrice('DESC')->get();
             break;
         case "4":
             $products = $products->orderByPrice()->get();
             break;
         default:
             $products = $products->get();
             break;
     }
     if (!$this->auth->guest()) {
         foreach ($products as $product) {
             $product->discountPrice();
         }
     } else {
         $products = $products->filter(function ($products) {
             return !$products->isOffer();
         });
     }
     return View::make('category.product', array('products' => $products, 'actualCategory' => $category, 'selected' => $order));
 }
開發者ID:villapilla,項目名稱:PHP,代碼行數:33,代碼來源:CategoriesController.php

示例12: showProductByCategory

 public function showProductByCategory($id, $slug = '')
 {
     $category = Category::findOrFail($id);
     $products = $category->products()->with('tags', 'category', 'picture')->paginate(5);
     $title = " Welcome category page {$category->title}";
     return view('front.category', compact('products', 'title'));
 }
開發者ID:patlegris,項目名稱:appStarWars,代碼行數:7,代碼來源:FrontController.php

示例13: category

 public function category($id)
 {
     $categories = $this->categories();
     $articles = Category::findOrFail($id)->articles()->orderBy('id', 'desc')->paginate(10);
     $category = Category::findOrFail($id);
     return view('home.category', compact('categories', 'articles', 'category'));
 }
開發者ID:hushibing,項目名稱:laravel51,代碼行數:7,代碼來源:HomeController.php

示例14: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(QuizRequest $request)
 {
     $cat = Category::findOrFail($request->input('cat_list'));
     $quiz = $cat->quizzes()->create($request->all());
     flash()->success('New Quiz has been created!');
     return redirect('quizzes');
 }
開發者ID:kkais,項目名稱:tests,代碼行數:12,代碼來源:QuizzesController.php

示例15: updateCategories

 public function updateCategories(Request $request)
 {
     foreach ($request->all() as $id => $data) {
         if ($id !== '_token') {
             if ($data['type'] == 'remove' && $id >= 1) {
                 $found = Category::findOrFail($id);
                 if ($found->products->isEmpty()) {
                     $found->delete();
                 }
             } else {
                 if ($data['name'] !== '' && $data['type'] !== '') {
                     if ($id >= 1) {
                         $found = Category::findOrFail($id);
                     } else {
                         $found = new Category();
                     }
                     $found->name = $data['name'];
                     $found->type = $data['type'];
                     $found->save();
                 }
             }
         }
     }
     return redirect()->route('categories.index');
 }
開發者ID:jhruby23,項目名稱:barapp,代碼行數:25,代碼來源:AdminController.php


注:本文中的app\Category::findOrFail方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。