public function toBag($id) { $product = Bag::where('productId', $id)->first(); $product->inBag = 1; $product->save(); return redirect()->action('HeartBagController@index'); }
public function checkout() { foreach (Auth::user()->bags->where('inBag', 1) as $bag) { $product = Product::find($bag->productId); $product->paid = 1; $product->save(); $bagNr = Bag::where('productId', $product->id)->first(); Auth::user()->bags()->detach($bagNr->id); } return redirect()->action('BagController@index'); }