public function postCart(Requests\CartRequest $request) { $products = Product::find(Input::get('id')); if (Input::get('qty') > 10) { return redirect('store/view/' . $products->id)->with('flash_message', 'Limit 10 Only'); } $id = $products->id; $name = $products->title; $cat = $products->category_id; $qty = Input::get('qty'); $color = Gambar::find(Input::get('color')); $size = Input::get('size'); $price = $products->price; $profit = $products->profit * 0.06; $img = Gambar::find(Input::get('color')); $data = array('id' => $id, 'name' => $name, 'qty' => $qty, 'price' => $price, 'profit' => $profit, 'options' => array('size' => $size, 'image' => $img->img, 'color' => $color->name, 'img_id' => $img->id, 'cat' => $cat)); Cart::add($data); return redirect('store/cart'); }
public function getView($id) { return view('store.show')->with('products', Product::find($id))->with('categories', Category::all())->with('db', Product::all())->with('options', Gambar::where('product_id', '=', $id)->lists('name', 'img')); }
public function postExtradestroy($id) { $gambar = Gambar::find($id); if (\Entrust::hasRole('Admin')) { $gambar = Gambar::find($id); if ($gambar) { File::delete(public_path($gambar->img)); $gambar->delete(); return redirect()->action('ProductController@getExtra', [$gambar->product_id])->with('flash_message', 'Product deleted'); } return redirect()->action('ProductController@getExtra', [$gambar->product_id])->with('flash_message', 'Something went wrong , please try again'); } return redirect('admin/products/extra/' . $gambar->product_id)->with('flash_message', 'You unable to destroy product extra image'); }