public function add($id)
 {
     $bag = new Bag();
     $bag->productId = $id;
     $bag->inBag = 0;
     $bag->save();
     $bag->users()->attach(Auth::user()->id);
     $bag->products()->attach($id);
     return redirect::back();
 }
 public function add($id)
 {
     $bag = Auth::user()->bags->where('productId', $id)->where('inBag', 1);
     if (count($bag) > 0) {
         return redirect()->action('BagController@index');
     }
     $bag = new Bag();
     $bag->productId = $id;
     $bag->inBag = 1;
     $bag->save();
     $bag->users()->attach(Auth::user()->id);
     $bag->products()->attach($id);
     if (count(Auth::user()->bags->where('productId', $id)->where('inBag', 0)) != 0 && Auth::user()->bags->where('productId', $id)->where('inBag', 0)->first()->exists()) {
         return redirect('heartbag/remove/' . $id);
     }
     return redirect::back();
 }