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


PHP Product::findOrFail方法代码示例

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


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

示例1: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int $id
  *
  * @return Response
  */
 public function update($id, Request $request)
 {
     $product = Product::findOrFail($id);
     $product->update($request->all());
     Session::flash('flash_message', 'Product updated!');
     return redirect('products');
 }
开发者ID:pavhov93,项目名称:blog2,代码行数:14,代码来源:ProductsController.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', 'description' => 'required', 'category_id' => 'required', 'purchase_price' => 'required', 'price' => 'required']);
     $product = Product::findOrFail($id);
     $product->update($request->all());
     Session::flash('flash_message', 'Product updated!');
     return redirect('backoffice/products');
 }
开发者ID:AntonBeletsky,项目名称:laravel_minishop,代码行数:15,代码来源:ProductsController.php

示例3: showProduct

 public function showProduct(Request $request, $id)
 {
     $product = Product::findOrFail($id);
     $active_menu = '';
     $topics = Topic::getProductTopics($id);
     $product_detail_topic = $product->detailTopic;
     return view('product', compact(['product', 'active_menu', 'topics', 'product_detail_topic']));
 }
开发者ID:jiketao,项目名称:jiketao-laravel,代码行数:8,代码来源:ProductController.php

示例4: update

 public function update(Request $request, $id)
 {
     $product = Product::findOrFail($id);
     $data = $request->only(['', '', '', '']);
     $product->fill($data);
     $product->save();
     return redirect()->action('ProductController@index');
     //PUT /resource/1
     //
 }
开发者ID:SaadEddinHassania,项目名称:hassania,代码行数:10,代码来源:ProductsController.php

示例5: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response|null
  */
 public function store(Request $request)
 {
     /**
      * @var $user \App\User
      */
     $user = \Auth::user();
     if (!$user) {
         return null;
     }
     $product_id = $request->get('product_id');
     $product_model = \App\Models\Product::findOrFail($product_id);
     $sql = 'INSERT IGNORE INTO ' . \App\Models\OrderedProduct::TABLE . ' (created_at, user_id, product_id, catalog_id, is_deferred) ' . 'VALUES (now(), ?, ?, ?, 1)';
     \DB::insert($sql, [$user->id, $product_id, $product_model->catalog_id]);
     return ['calls' => [['call' => 'updateHtmlContext', 'params' => ['#product-mini-item-' . $product_id, view('catalog.product_mini_item', ['product' => $product_model])->render()]], ['call' => 'updateHtmlContext', 'params' => ['#basket-mini-box', view('basket.mini_box')->render()]], ['call' => 'updateHtmlContext', 'params' => ['#basket-orders-container', view('basket.orders_items')->render()]]]];
 }
开发者ID:serovvitaly,项目名称:kotik,代码行数:21,代码来源:DeferredController.php

示例6: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response|null
  */
 public function store(Request $request)
 {
     /**
      * @var $user \App\User
      */
     $user = \Auth::user();
     if (!$user) {
         return null;
     }
     $product_id = $request->get('product_id');
     $product_model = \App\Models\Product::findOrFail($product_id);
     $sql = 'INSERT INTO ' . \App\Models\OrderedProduct::TABLE . ' (created_at, user_id, product_id, catalog_id, price, quantity) ' . 'VALUES (now(), ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE quantity = quantity + ?, updated_at = now()';
     $public_price = $product_model->getPublicPrice();
     $quantity = $request->get('quantity');
     \DB::insert($sql, [$user->id, $product_id, $product_model->catalog_id, $public_price, $quantity, $quantity]);
     return ['calls' => [['call' => 'updateHtmlContext', 'params' => ['#product-mini-item-' . $product_id, view('catalog.product_mini_item', ['product' => $product_model])->render()]], ['call' => 'updateHtmlContext', 'params' => ['#basket-mini-box', view('basket.mini_box')->render()]], ['call' => 'updateHtmlContext', 'params' => ['#basket-orders-container', view('basket.orders_items')->render()]]]];
 }
开发者ID:serovvitaly,项目名称:kotik,代码行数:23,代码来源:OrderController.php

示例7: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $product = Product::findOrFail($id);
     $rating_cont = Comment::where('product_id', '=', $product->id)->count();
     $checked_rating_count = $rating_cont > 0 ? $rating_cont : 1;
     $five_star = Comment::where('product_id', '=', $product->id)->where('rating', '=', '5')->count() * 100 / $checked_rating_count;
     $four_star = Comment::where('product_id', '=', $product->id)->where('rating', '=', '4')->count() * 100 / $checked_rating_count;
     $three_star = Comment::where('product_id', '=', $product->id)->where('rating', '=', '3')->count() * 100 / $checked_rating_count;
     $two_star = Comment::where('product_id', '=', $product->id)->where('rating', '=', '2')->count() * 100 / $checked_rating_count;
     $one_star = Comment::where('product_id', '=', $product->id)->where('rating', '=', '1')->count() * 100 / $checked_rating_count;
     $owner = $product->owner();
     $mods = $product->mods();
     if (empty($product)) {
         Flash::error('Product not found');
         return redirect(route('admin.products.index'));
     }
     return view('site.products.show')->with(['product' => $product, 'rating_count' => $rating_cont, 'five_star' => $five_star, 'four_star' => $four_star, 'three_star' => $three_star, 'two_star' => $two_star, 'one_star' => $one_star, 'owner' => $owner, 'mods' => $mods]);
 }
开发者ID:jclyons52,项目名称:mycourse-rocks,代码行数:24,代码来源:ProductController.php

示例8: getActualOffersProducts

 public static function getActualOffersProducts()
 {
     return \App\Models\ProductInPurchase::paginate(20);
     return \App\Models\Product::where('status', '=', 1)->paginate(20);
     $sql = "select ps.product_id\n            from catalogs ct\n            join products_offers ps on ct.id = ps.catalog_id\n            where ct.status = 1 and ps.status = 1 limit 20";
     $products_ids_obj_arr = \DB::select($sql);
     if (empty($products_ids_obj_arr)) {
         return [];
     }
     $products = [];
     foreach ($products_ids_obj_arr as $product_obj) {
         $products[] = \App\Models\Product::findOrFail($product_obj->product_id);
     }
     //print_r($products); exit;
     return $products;
     $products = \App\Models\Product::where('status', '>', 0)->where('price_1', '>', 0)->paginate(20);
     return $products;
 }
开发者ID:serovvitaly,项目名称:kotik,代码行数:18,代码来源:CatalogViewerHelper.php

示例9: add

 public function add($id)
 {
     $order = Order::where('id', '=', $id)->where('user_id', '=', Auth::user()->id)->first();
     //$orderItem = $order->items()->findOrFail($id);
     //$productId = $order->items()->findOrFail($itemId);
     $orderItem = $order->items()->where('product_id', '=', (int) Input::get("product_id"))->first();
     if ($orderItem) {
         $orderItem->quantity += (int) Input::get("quantity");
         $orderItem->save();
     } else {
         $product = Product::findOrFail((int) Input::get("product_id"));
         $orderItem = new OrderItem();
         $orderItem->order_id = $id;
         $orderItem->product_id = $product->id;
         $orderItem->price = $product->price;
         $orderItem->quantity = (int) Input::get("quantity");
         $orderItem->save();
     }
     $this->recalculateDelivery($order);
     return $this->orderToJson($order);
 }
开发者ID:artyomich,项目名称:laravel,代码行数:21,代码来源:OrderItemController.php

示例10: index

 /**
  * Display Generator Page
  * @param $product_id
  * @return $this
  */
 public function index($product_id)
 {
     $product = $this->product->findOrFail($product_id);
     return view('products.codes.index', compact('product'))->with('codes', $product->codes()->simplePaginate());
 }
开发者ID:SkysoulDesign,项目名称:mirage.dev,代码行数:10,代码来源:CodeController.php

示例11: destroy

 public function destroy(Request $request, $id)
 {
     Product::findOrFail($id)->delete();
     return redirect()->route('product.index')->with('success_message', 'The product has been successfully deleted.');
 }
开发者ID:rundef,项目名称:laravel_backbone,代码行数:5,代码来源:ProductController.php

示例12: addItem

 public function addItem($product_id, $quantity)
 {
     $product = Product::findOrFail($product_id);
     $params = ['order_id' => $this->id, 'product_id' => $product->id, 'quantity' => $quantity, 'price' => $product->price * $quantity];
     return OrderItem::create($params);
 }
开发者ID:nkiermaier,项目名称:laravel_ecommerce,代码行数:6,代码来源:Order.php

示例13: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  *
  * @return Response
  */
 public function show($id)
 {
     $product = Product::findOrFail($id);
     return view('frontoffice.products.show', compact('product'));
 }
开发者ID:AntonBeletsky,项目名称:laravel_minishop,代码行数:12,代码来源:ProductsController.php

示例14: edit

 public function edit($id)
 {
     $product = Product::findOrFail($id);
     return view('productStockInitializations.edit', compact('product'));
 }
开发者ID:saj696,项目名称:pipe,代码行数:5,代码来源:ProductStockInitializationsController.php

示例15: edit

 public function edit($id)
 {
     $data = Product::findOrFail($id);
     $select = Category::all('id', 'menu_name');
     return view('admin.product.edit', ['data' => $data, 'select' => $select]);
 }
开发者ID:shegun-babs,项目名称:dakrush,代码行数:6,代码来源:ProductController.php


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