/**
  * consultar produto
  * @param $id id do produto
  */
 public function product($id)
 {
     $categories = Category::all();
     $product = Product::find($id);
     $tags = $product->tags;
     return view('store.product', compact('categories', 'product', 'tags'));
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $product = Product::find($id);
     $product->delete();
     Session::flash('message', 'successfully deleted the product!');
     return Redirect::to('products');
 }
Exemplo n.º 3
0
 /**
  * Add product to Cart.
  * @param $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function add($id)
 {
     $cart = $this->getCart();
     $product = Product::find($id);
     $cart->add($id, $product->name, $product->price);
     return redirect()->route('cart');
 }
 public function remove($id)
 {
     $product = Product::find($id);
     $cart = $this->getCart();
     $cart->remove($product->id);
     Session::set('cart', $cart);
     return redirect()->route('cart');
 }
 public function add($id)
 {
     $cart = $this->getCart();
     $product = Product::find($id);
     $cart->add($product);
     Session::set('cart', $cart);
     return redirect()->route('store.cart');
 }
Exemplo n.º 6
0
 public function add($id, Product $prod)
 {
     $cart = $this->getCart();
     $product = $prod->find($id);
     $cart->add($id, $product->name, $product->price);
     Session::set('cart', $cart);
     return redirect()->route('cart');
 }
Exemplo n.º 7
0
 public function productDetail(Category $category, Product $products, $id)
 {
     $categories = $category->all();
     $product = $products->find($id);
     $tags = $this->tag->all();
     //  dd($product->tags);
     return view('store.productDetail', compact('categories', 'product', 'tags'));
 }
 public function add($id)
 {
     $cart = $this->getCart();
     $product = Product::find($id);
     $image = $product->images->first() ? 'uploads' . '/' . $product->images->first()->id . '.' . $product->images->first()->extension : 'images/no-img.jpg';
     $cart->add($id, $product->name, $product->price, $image);
     Session::set('cart', $cart);
     return redirect()->route('store.cart');
 }
 public function destroy($id)
 {
     $model = Product::find($id);
     foreach ($model->images()->getResults() as $image) {
         $this->destroyImage($image, $image->id);
     }
     $model->delete();
     return redirect()->route('products');
 }
Exemplo n.º 10
0
 public function product($id)
 {
     $product = Product::find($id);
     if ($product) {
         $categories = Category::all();
         return view('store.details', compact('categories', 'product'));
     } else {
         return redirect()->route('store.index');
     }
 }
Exemplo n.º 11
0
 public function add($id)
 {
     $cart = $this->getCart();
     //Adiciona os atributo no carrinho
     $product = Product::find($id);
     $cart->add($id, $product->name, $product->price);
     //Altera a sessão passando o Carrinho
     Session::set('cart', $cart);
     return redirect()->route('cart');
 }
Exemplo n.º 12
0
    public function removeItem($id)
    {
        $cart = $this->getCart();

        $product = Product::find($id);

        $cart->removeItem($id, $product->name, $product->price);

        Session::set('cart', $cart);

        return redirect()->route('store.cart');
    }
Exemplo n.º 13
0
 public function update(\CodeCommerce\Http\Requests\CartRequest $request, $id, Session $session)
 {
     $data = $request->all();
     $cart = $this->getCart($session);
     $product = Product::find($id);
     $cart->update($id, $product->name, $product->price, $data['qtd']);
     if ($data['qtd'] == 0) {
         $cart->remove($id);
     }
     $session::set('cart', $cart);
     return redirect()->route('cart');
 }
Exemplo n.º 14
0
 public function update($id, $quantity, Request $request)
 {
     if ($request->ajax()) {
         $cart = $this->getCart();
         if ($cart->setQuantity($id, $quantity)) {
             Session::set('cart', $cart);
             $product = Product::find($id);
             return ['success' => true, 'price' => number_format($product->price * $quantity, 2, ',', '.'), 'total' => number_format($cart->getTotal(), 2, ',', '.')];
         }
         return ['success' => false];
     }
 }
Exemplo n.º 15
0
 public function updateItem(Requests\CartRequest $cartRequest)
 {
     $input = $cartRequest->all();
     $id = $input['id'];
     $quantity = $input['quantity'];
     $cart = $this->getCart();
     $product = Product::find($id);
     $cart->addMoreThanOneQuantity($id, $product->name, $product->price, $quantity);
     Session::set('cart', $cart);
     $subTotal = $product->price * $cart->all()[$id]['qtd'];
     $items = $cart->all();
     return response()->json(['subTotal' => $subTotal, 'total' => $cart->getTotal(), 'qtd' => $items[$id]['qtd']]);
 }
Exemplo n.º 16
0
 private function syncTags($tagList, $id)
 {
     $syncTag = [];
     $tags = explode(',', str_replace(';', ',', $tagList));
     $tags = array_filter($tags);
     $tags = array_map('trim', $tags);
     $tags = array_map('strip_tags', $tags);
     $tags = array_map('strtolower', $tags);
     foreach ($tags as $tag) {
         $syncTag[] = $this->tag->firstOrCreate(['name' => $tag])->id;
     }
     $product = $this->product->find($id);
     $product->tags()->sync($syncTag);
 }
 public function add($id)
 {
     $cart = $this->getCart();
     $product = Product::find($id);
     $img = $product->firstImageName();
     if ($img) {
         //caminho da imagem
         $imgPath = url('uploads/' . $img);
     } else {
         $imgPath = url('build/images/no-img.jpg');
     }
     $cart->add($product->id, $product->name, $product->price, $imgPath);
     Session::set('cart', $cart);
     return redirect()->route('store.cart');
 }
Exemplo n.º 18
0
 /**
  * Add Items to Cart.
  *
  * @param $id
  * @return \Illuminate\Http\Response
  */
 public function add(Request $request, $id)
 {
     // trago o metodo
     $cart = $this->getCart();
     // Importo e pego o meu produto
     $product = Product::find($id);
     // pego a cor
     $color = $request->get('color');
     // verifico se a cor é formato HEX
     if (preg_match('/^#[a-f0-9]{6}$/i', $color)) {
         // adiciono o produto ao carrinho
         $cart->add($id, $product->name, $product->price, $color);
         // adiciono o carrinho alterado/final a minha sessão
         Session::set('cart', $cart);
     } else {
         return redirect()->route('store.product', ['id' => $id])->withError('Por favor, selecione uma Cor para o produto!');
     }
     return redirect()->route('cart');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\ProductRequest  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Requests\ProductRequest $request, $id)
 {
     $input = $request->all();
     $input['featured'] = $request->get('featured') ? true : false;
     $input['recommend'] = $request->get('recommend') ? true : false;
     $arrayTags = $this->tagToArray($input['tags']);
     $this->productModel->find($id)->update($input);
     $product = Product::find($id);
     $product->tags()->sync($arrayTags);
     return redirect()->route('admin.products.index');
 }
Exemplo n.º 20
0
 public function product($id)
 {
     $categories = Category::Available()->get();
     $product = Product::find($id);
     return view('store.product', compact('categories', 'product'));
 }
Exemplo n.º 21
0
 public function ProductDetails($id)
 {
     $categories = $this->category->all();
     $product = $this->product->find($id);
     return view('store.product_detail', compact('product', 'categories'));
 }
Exemplo n.º 22
0
 public function product($id)
 {
     $categories = $this->category->all();
     $product = $this->product->find($id);
     return view('store.product', compact('categories', 'product'));
 }
 /**
  * @param $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function destroy($id)
 {
     $this->product->find($id)->delete();
     return redirect()->route('products');
 }
 public function createImage($id)
 {
     $product = $this->product->find($id);
     return view('admin.products.createimage', compact('product'));
 }
Exemplo n.º 25
0
 /**
  * @param $id
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function product($id)
 {
     $product = Product::find($id);
     return view('store.product', compact('product'));
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $product = $this->product->find($id);
     return $product->name;
 }
Exemplo n.º 27
0
 public function product($id, Category $cat, Product $prod)
 {
     $categories = $cat->all();
     $product = $prod->find($id);
     return view('store.product', compact('categories', 'product'));
 }
 public function imageCreate($id)
 {
     $product = $this->model->find($id);
     return view('products.images.create', compact('product'));
 }