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


PHP Product::find方法代码示例

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


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

示例1: add

 /**
  * Add item to the cart.
  *
  * @param $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function add($id)
 {
     $cart = $this->getCart();
     $product = $this->product->find($id);
     $cart->add($id, $product->name, $product->price);
     $this->session->set('cart', $cart);
     return redirect()->route('cart');
 }
开发者ID:JimiOhrid,项目名称:shopStore,代码行数:14,代码来源:CartController.php

示例2: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $product = Product::find($id);
     $product->browsed++;
     $product->save();
     return view('product.show', ['product' => $product]);
 }
开发者ID:paolo-arancibia,项目名称:logi,代码行数:13,代码来源:ProductsController.php

示例3: show

 /**
  * falta por implementar, no se usa por el momento
  *
  **/
 public function show($id)
 {
     $product = Product::find($id);
     $relatedProducts = Product::where('category', '=', $product->category)->where('id', '!=', $product->id)->take(4)->get();
     //dd($relatedProducts);
     return view('pages.show')->with(['product' => $product, 'relatedProducts' => $relatedProducts]);
 }
开发者ID:angelsalazar,项目名称:plazaapp,代码行数:11,代码来源:PagesController.php

示例4: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $order = new \App\Order($request->all());
     $cart = $request->session()->get('cart', function () {
         return null;
     });
     if ($cart == null) {
         return redirect('cart');
     }
     DB::transaction(function () use($order, $cart) {
         $order->save();
         $total = 0;
         foreach ($cart as $id => $qty) {
             if ($qty <= 0) {
                 continue;
             }
             $pro = \App\Product::find($id);
             $od = new \App\OrderDetail();
             $od->price = $pro->price;
             $od->quantity = $qty;
             $od->product()->associate($pro);
             $od->order()->associate($order);
             $od->save();
             $total += $qty * $pro->price;
         }
         if ($total > 0) {
             $order->status = 1;
             //????????????
             $order->total = $total;
             $order->update();
         }
     });
     $request->session()->forget('cart');
     return redirect('order');
 }
开发者ID:nakedwarrior,项目名称:larashop,代码行数:41,代码来源:OrderController.php

示例5: update

 public function update(Request $request, $id)
 {
     $category = Category::find($id);
     $category->name = $request->name;
     $category->is_active = $request->is_active;
     if (!is_null($request->products)) {
         if (!is_null($category->Product)) {
             foreach ($category->Product as $product) {
                 $product->category = NULL;
                 $product->save();
             }
         }
         foreach ($request->products as $id) {
             $obj = Product::find($id);
             $obj->category = $category->id;
             $obj->save();
         }
     }
     if (!empty($request->image)) {
         File::delete(public_path($category->path));
         $img = $request->image;
         $imgName = $img->getClientOriginalName();
         $path = "/catalog/img/brand/" . $category->id . "/";
         $category->path = $path . $imgName;
         $img->move(public_path($path), $imgName);
         $category->save();
     }
     $category->save();
     return redirect('admin/category');
 }
开发者ID:Peelz,项目名称:bait,代码行数:30,代码来源:CategoryController.php

示例6: getSetDone

 public function getSetDone($id)
 {
     $product = Product::find($id);
     $product->status = 'done';
     $product->save();
     return response()->json(true);
 }
开发者ID:jonasdahl,项目名称:mammeriet,代码行数:7,代码来源:ApiController.php

示例7: showProduct

 public function showProduct($id)
 {
     $product = Product::find($id);
     // Get all reviews that are not spam for the product and paginate them
     $reviews = $product->reviews()->with('user')->approved()->notSpam()->orderBy('created_at', 'desc')->paginate(10);
     return \View::make('products.show', array('product' => $product, 'reviews' => $reviews));
 }
开发者ID:xenxa,项目名称:essensanaturaleonline,代码行数:7,代码来源:ProductController.php

示例8: store

 /**
  * Create a new product.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['name' => 'required|max:255', 'store_id' => 'required', 'location_id' => 'required', 'source_id' => 'required']);
     if (!$request->id) {
         $request->quantity = $request->quantity ? $request->quantity : 1;
         Product::create(['name' => $request->name, 'store_id' => $request->store_id, 'location_id' => $request->location_id, 'source_id' => $request->source_id, 'purchase_price' => $request->purchase_price, 'sale_price' => $request->sale_price, 'shipping_paid' => $request->shipping_paid, 'actual_shipping' => $request->actual_shipping, 'seller_fee' => $request->seller_fee, 'shipping_fee' => $request->shipping_fee, 'product_status' => $request->product_status, 'quantity' => $request->quantity, 'quantity_sold' => $request->quantity_sold, 'improvement_hours' => $request->improvement_hours, 'improvement_dollars' => $request->improvement_dollars]);
     } else {
         $product = Product::find($request->id);
         $product->name = $request->name;
         $product->store_id = $request->store_id;
         $product->location_id = $request->location_id;
         $product->source_id = $request->source_id;
         $product->purchase_price = $request->purchase_price;
         $product->sale_price = $request->sale_price;
         $product->shipping_paid = $request->shipping_paid;
         $product->actual_shipping = $request->actual_shipping;
         $product->seller_fee = $request->seller_fee;
         $product->shipping_fee = $request->shipping_fee;
         $product->product_status = $request->product_status;
         $product->quantity = $request->quantity;
         $product->quantity_sold = $request->quantity_sold;
         $product->improvement_hours = $request->improvement_hours;
         $product->improvement_dollars = $request->improvement_dollars;
         $product->save();
     }
     if ($request->submit == 'Save') {
         return redirect('/product');
     } else {
         return redirect('/product/create?source=' . $request->source_id . '&store=' . $request->store_id . '&location_id=' . $request->location_id);
     }
     return redirect('/product');
 }
开发者ID:aducworth,项目名称:inventory,代码行数:38,代码来源:ProductController.php

示例9: deleteKey

 /**
  *	delete key registered (Only this seller)
  *	@param	$id 	int|string 	id the virtual product
  *	@param	$res 	Request 	object to validate the type of request, action
  *	@return	json
  */
 public function deleteKey($id, Request $res)
 {
     if (!$res->wantsJson()) {
         return redirect()->back();
     }
     $VirtualProduct = VirtualProduct::find($id);
     if (!count($VirtualProduct->toArray())) {
         return json_encode(['message' => trans('globals.error_not_available')]);
     }
     $product = Product::find($VirtualProduct->product_id);
     if (!count($product->toArray())) {
         return json_encode(['message' => trans('globals.error_not_available')]);
     }
     if ($product->user_id != \Auth::id()) {
         return json_encode(['message' => trans('globals.not_access')]);
     }
     $VirtualProductOrder = VirtualProductOrder::where('virtual_product_id', $VirtualProduct->id)->get();
     if (count($VirtualProductOrder->toArray()) > 0) {
         return json_encode(['message' => trans('product.virtualProductsController_controller.key_been_sold')]);
     }
     $VirtualProduct->status = 'cancelled';
     $VirtualProduct->save();
     $stock = count(VirtualProduct::where('product_id', $product->id)->where('status', 'open')->get()->toArray());
     $product->stock = $stock;
     if ($stock == 0) {
         $product->status = 0;
     }
     $product->save();
     return json_encode(['success' => trans('product.controller.saved_successfully')]);
 }
开发者ID:masterpowers,项目名称:antVel,代码行数:36,代码来源:VirtualProductsController.php

示例10: cart

 public function cart()
 {
     if (Request::isMethod('post')) {
         $product_id = Request::get('product_id');
         $product = Product::find($product_id);
         Cart::add(array('id' => $product_id, 'name' => $product->name, 'qty' => 1, 'price' => $product->price));
     }
     if (Request::get('product_id')) {
         $rowId = Cart::search(array('id' => Request::get('product_id')));
         $item = Cart::get($rowId[0]);
         if (Request::get('increment') == 1) {
             Cart::update($rowId[0], $item->qty + 1);
         } else {
             if (Request::get('decrement') == 1) {
                 Cart::update($rowId[0], $item->qty - 1);
             } else {
                 if (Request::get('delete') == 1) {
                     Cart::remove($rowId[0]);
                 }
             }
         }
     } else {
         if (Request::get('clear_cart') == 1) {
             Cart::destroy();
         }
     }
     $cart = Cart::content();
     return view('cart', array('cart' => $cart, 'title' => 'Welcome', 'description' => '', 'page' => 'home'));
 }
开发者ID:jmgolz,项目名称:php-laravel-blog,代码行数:29,代码来源:Front.php

示例11: show_for_other_user

 public function show_for_other_user($user_id)
 {
     $list = Lists::where('user_id', '=', $user_id)->get();
     $user_list = [];
     foreach ($list as $pro) {
         $product_id = $pro->product_id;
         $product = Product::find($product_id);
         if ($product != null) {
             $created_by = $product['created_by'];
             $category = Category::find($product['category_id']);
             $category = $category['category'];
             $user = User::find($created_by);
             array_add($product, 'category', $category);
             array_add($product, 'created_by_name', $user['name']);
             $initial = explode(".", $product['image_url']);
             $thumbFirst = "";
             for ($i = 0; $i < sizeof($initial) - 1; $i++) {
                 $thumbFirst = $thumbFirst . $initial[$i];
             }
             $thumbnail = $thumbFirst . '-130x90.' . $initial[sizeof($initial) - 1];
             //thumb size changed
             array_add($product, 'thumbnail', $thumbnail);
             array_push($user_list, $product);
         }
     }
     return response()->json(['list' => $user_list]);
 }
开发者ID:ShehabSunny,项目名称:ProductZap,代码行数:27,代码来源:ListController.php

示例12: showByUser

 public function showByUser($user_id)
 {
     //directly copied pasted from list controller.
     $list = Vote::where('user_id', '=', $user_id)->get();
     $user_list = [];
     foreach ($list as $pro) {
         $product_id = $pro->product_id;
         $product = Product::find($product_id);
         if ($product != null) {
             $created_by = $product['created_by'];
             $category = Category::find($product['category_id']);
             $category = $category['category'];
             $user = User::find($created_by);
             array_add($product, 'category', $category);
             array_add($product, 'created_by_name', $user['name']);
             $initial = explode(".", $product['image_url']);
             $thumbFirst = "";
             for ($i = 0; $i < sizeof($initial) - 1; $i++) {
                 $thumbFirst = $thumbFirst . $initial[$i];
             }
             $thumbnail = $thumbFirst . '-200x200.' . $initial[sizeof($initial) - 1];
             array_add($product, 'thumbnail', $thumbnail);
             array_push($user_list, $product);
         }
     }
     return $user_list;
     //        return response()->json([
     //                'upvotted'=>$user_list]
     //        );
 }
开发者ID:ShehabSunny,项目名称:ProductZap,代码行数:30,代码来源:VotesController.php

示例13: addItem

 public function addItem(Request $request, $productId)
 {
     #check service
     $product = Product::find($productId);
     if (!$product) {
         return redirect()->route("home")->with("error", "No product select");
     }
     $qty = $request->get("qty", 0);
     $user = Sentinel::getUser();
     $cart = $this->_createCart();
     $this->billing($cart, $request);
     $cartItem = new Cartitem();
     $cartItem->product_id = $productId;
     $cartItem->cart_id = $cart->id;
     $cartItem->quantity = $qty;
     $cartItem->track_num = $request->get('track_num', '');
     $cartItem->carrier = $request->get('carrier', '');
     $cartItem->unit_price = $product->price;
     $cartItem->save();
     for ($i = 0; $i < $qty; $i++) {
         if (!$request->has("passenger_id-" . $i)) {
             $birthdate = $request->get("year-dob-" . $i) . '-' . $request->get("month-dob-" . $i) . '-' . $request->get("day-dob-" . $i);
             $passport_expirate = $request->get("year-passportExp-" . $i) . '-' . $request->get("month-passportExp-" . $i) . '-' . $request->get("day-passportExp-" . $i);
             $passenger = Passenger::create(['first_name' => $request->get("fname-" . $i), 'last_name' => $request->get("lname-" . $i), 'gender' => $request->get("gender-" . $i), 'birthdate' => $birthdate, 'passport_num' => $request->get("passport-" . $i), 'passport_expirate' => $passport_expirate]);
         }
         $passenger->cartitem()->attach($cartItem);
     }
     return redirect('/cart');
 }
开发者ID:zangee3,项目名称:avs,代码行数:29,代码来源:CartController.php

示例14: saveOptions

 public function saveOptions($id, Request $request)
 {
     $product = \App\Product::find($id);
     $options = $request->get('options');
     $product->update(['options' => $options]);
     return $product->options;
 }
开发者ID:stjanilofts,项目名称:kl,代码行数:7,代码来源:ProductController.php

示例15: product

 public function product($id)
 {
     // Product Detail
     $product = Product::find($id);
     $producer = Producer::find($product->producer);
     $producerItem = "<a href='" . URL::to('/') . "/producer/" . $producer->id . "/" . strtolower($producer->producer) . ".html'>" . $producer->producer . "</a>";
     // Category
     $productCategoryID = Product::find($id)->category_id;
     // breadcrumb
     $breadcrumb = $this->breadcrumb($productCategoryID, $id);
     // Best Seller
     $bestSeller = $this->bestSeller();
     $image = Images::where('productID', $product['id'])->first();
     $thumbnail = $image['imageSrc'];
     $thumbnailImage = '<a class="preView" rel="' . URL::to('/') . '/' . $thumbnail . '"><img src="' . URL::to('/') . '/' . $thumbnail . '" alt="" class="img-responsive"></a>';
     $images = Images::where('productID', $id)->get();
     $listImages = "";
     foreach ($images as $image) {
         $img = $image['imageSrc'];
         $listImages .= '<a href="' . URL::to('/') . '/' . $img . '" class="fancybox-button" rel="photos-lib"><img alt="Berry Lace Dress" src="' . URL::to('/') . '/' . $img . '"></a>';
     }
     $review = '<div class="fb-comments" data-href="' . URL::to('/') . '/product/' . $id . '"
             data-num-posts="10" data-width="700px"></div>';
     return view('home.product.detail')->with(['breadcrumb' => $breadcrumb, 'product' => $product, 'producer' => $producerItem, 'bestSeller' => $bestSeller, 'thumbnailImage' => $thumbnailImage, 'listImages' => $listImages, 'review' => $review]);
 }
开发者ID:dhduc,项目名称:shopui,代码行数:25,代码来源:ProductController.php


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