当前位置: 首页>>代码示例>>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;未经允许,请勿转载。