public function checkOut() { $order = new \App\Models\Order(); $order->user_id = \Auth::user()->id; $order->status = 'Pending'; $order->save(); foreach (\Cart::contents() as $item) { $order->products()->attach($item->id, ['quantity' => $item->quantity]); } \Cart::destroy(); return redirect('types/1'); }
public function checkout() { $order = new \App\Models\Order(); $order->user_id = \Auth::user()->id; $order->status = "Pending"; $order->save(); foreach (Cart::contents() as $item) { $order->products()->attach($item->id, ["quantity" => $item->quantity]); } Cart::destroy(); return redirect("types/1"); }