Example #1
0
 public function delete($id)
 {
     $product = Product::findOrFail($id);
     $cart = \Session::get('cart');
     unset($cart[$product->id]);
     \Session::put('cart', $cart);
     return redirect()->route('cart-show');
 }
Example #2
0
 public function viewShop($id)
 {
     $product = Product::findOrFail($id);
     return view('shop.product', ['product' => $product]);
 }
Example #3
0
 public function addmultipleimg(Request $request)
 {
     $files = $request->file('images');
     $idproduct = $request->input('productId');
     $count = 1;
     foreach ($files as $file) {
         $rules = array('file' => 'required||mimes:png,gif,jpeg,jpg');
         //'required|mimes:png,gif,jpeg,txt,pdf,doc'
         $validator = Validator::make(array('file' => $file), $rules);
         if ($validator->passes()) {
             $product = Product::findOrFail($idproduct);
             $newImg = new ProductImg();
             $newImg->product_id = $product->id;
             $newImg->desc = $file->getClientOriginalName();
             $newImg->orden = $count;
             $newImg->save();
             //$file = $request->file('image');
             $path = public_path() . '/img/products/';
             $name = $newImg->id . $file->getClientOriginalName();
             $image = \Image::make($file);
             // Guardar Original
             //$image->fit(320, 320);
             $image->save($path . $name);
             // Cambiar de tamaƱo
             //$image->fit(120, 120);
             // Guarda
             $image->save($path . 'thumb_' . $name);
             //Guarda img DB
             $newImg->url = $name;
             $newImg->save();
             $count++;
         }
     }
     return $this->edit($idproduct);
 }