public function storeWishedProduct($id, $user_id)
 {
     $item = Wishlist::where('product_id', '=', $id)->where('user_id', '=', $user_id)->get();
     if (count($item)) {
         echo "<script>\n\t\t\t\t\talert('This Product is in your Wishlist already!');\n\t\t\t\t\twindow.history.back();\n    \t\t\t\t</script>";
     } else {
         $item = Product::find($id);
         Wishlist::create(['user_id' => $user_id, 'product_id' => $id, 'brand_id' => $item->brand_id, 'type_id' => $item->type_id]);
         return redirect()->route('detail', compact('id'));
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     if ($customer = $this->getRentalHistory($id)) {
         $reviews = Review::where('customer_id', $id)->with('movie')->get()->toArray();
         $wishlist = Wishlist::where('customer_id', $id)->with('movies')->get()->toArray();
         // dd($wishlist);
         return view('customers.show')->with('customer', $customer)->with('reviews', $reviews)->with('wishlist', $wishlist);
     }
     // User doesn't exist for this account
     $this->setMessage('Customer not found!', 'error');
     return redirect('/customers');
 }
 public function wishlist($id)
 {
     $page = 'partials.profile-wishlist';
     $items = Wishlist::where('user_id', '=', $id)->get();
     $products = Product::all();
     $brands = Brand::all();
     $types = Type::all();
     return view('webcontent/profile', compact('page', 'items', 'products', 'brands', 'types'));
 }
 private function removeFromWishlist($customer, $movie)
 {
     if ($wl = Wishlist::where('customer_id', $customer)->where('movie_id', $movie)->first()) {
         $wl->delete();
     }
     return;
 }