Example #1
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $product = Product::findOrFail($id);
     $category = Category::findOrFail($product->category_id);
     $product_sizes = ProductSize::where('product_id', '=', $id)->get();
     return view('product.show', compact('product', 'category', 'product_sizes'));
 }
Example #2
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $extra = Extra::findOrFail($id);
     $product_size = ProductSize::findOrFail($extra->product_size_id);
     $product = Product::findOrFail($product_size->product_id);
     $category = Category::findOrFail($product->category_id);
     $product_sizes = ProductSize::where('product_id', '=', $product->id)->lists('size', 'id');
     return view('extra.edit', compact('product_size', 'product', 'category', 'product_sizes', 'extra'));
 }
 public function edit($id_product, $id)
 {
     $variant = ProductVariant::find($id);
     $prod = Product::find($id_product);
     $size = ProductSize::where('id_variants', $id)->get();
     $check = $variant->publish;
     if ($check == 0) {
         $checks = '';
     } else {
         $checks = 'checked';
     }
     $categories = Category::all();
     return view('dropmin/variant/edit')->with('variant', $variant)->with('check', $checks)->with('size', $size)->with('prod', $prod);
 }
Example #4
0
 public function addCart(Request $request)
 {
     $keys = 'psid,count,quickly';
     $data = $this->tipsValidate($request, 'order.cart', $keys);
     $psid = $data['psid'];
     DB::beginTransaction();
     $ps = ProductSize::where('id', $psid)->lockForUpdate()->first();
     //库存不足
     if ($ps->count < $data['count']) {
         DB::rollback();
         return $this->failure('order.failure_cart_stock_less');
     }
     //快速购买模式
     if ($data['quickly']) {
         DB::rollback();
         return $this->success('order.success_quickly', url('m/to/order') . '?cart[]=' . $psid . '&buy_cnt[' . $psid . ']=' . $data['count']);
     } else {
         //加入购物车
         Cart::firstOrCreate(['psid' => $psid, 'uid' => $this->user->getKey()])->increment('count', $data['count']);
         DB::commit();
         return $this->success('order.success_cart', FALSE);
     }
 }