public function view($slug)
 {
     $product = Product::where('slug', '=', $slug)->get()->first();
     //Get Product Price @todo
     $price = $product->getPrice();
     return view('front.product.view')->with('product', $product)->with('price', $price);
 }
 /**
  * Add to cart the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function addtocart($id, Request $request)
 {
     $product = Product::findorfail($id);
     $session = $request->session();
     //Manually Empty Cart here
     //$session->forget('cart');
     $cartData = $session->get('cart') ? $session->get('cart') : array();
     if (array_key_exists($product->id, $cartData)) {
         $cartData[$product->id]['qty']++;
     } else {
         $cartData[$product->id] = array('id' => $product->id, 'name' => $product->name, 'image' => isset($product->images()->first()->path) ? $product->images()->first()->path : 'http://placehold.it/500x500', 'price' => $product->getPrice(), 'qty' => 1);
     }
     $request->session()->put('cart', $cartData);
     return redirect()->back()->with('message', 'Prodcut Added Successfully!');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  Request $request
  * @param  int $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $product = Product::find($id);
     $product->update($request->all());
     //Save Product Images
     $this->saveProductImages($request->get('productImage'), $id);
     //Save Product Images
     $this->saveProductPrices($request->get('price'), $id);
     //Save Product Categoryies
     $this->saveCategories($request->get('categories'), $id);
     //Save Product Attributes
     //$attributes = $request->get('attribute');
     //$this->saveAttribute($attributes, $id);
     if ($product->slug == "") {
         $product->slug = str_slug($request->get('name'));
         //update File Path and Slug
         $product->save();
     }
     return redirect("/admin/product");
 }