public function addToCart(Request $req) { $user = $req->user; $cart = Cart::firstOrCreate(['user_id' => $user, 'status' => "pending"]); $addProduct = new CartOrder(); $addProduct->cart_id = $cart->id; $addProduct->pro_id = $req->product; $addProduct->quanlity = $req->qty; $addProduct->save(); return redirect('/'); }
static function getLast($count) { $Last = CartOrder::orderBy('created_at', 'desc')->take($count)->get(); return $Last; }