Level 56
Hi @war3_brent2 usually I use observers from this. You can observe created event for Order model and decrease quantity of associated products
Summer Sale! All accounts are 50% off this week.
Good Day I need your help. How can I decrement a quantity of a specific item in the table after I do the checkout?. Cant really think of a way how to do it. Thank you for the reply
public function postCheckout(Request $request){
if (!Session::has('cart')){
return view('shop.shoppingcart');
}
$oldCart = Session::get('cart');
$cart = new Cart($oldCart);
$order = new Order();
$order->cart = serialize($cart);
$order->address = $request->input('address');
$order->name = $request->input('name');
Auth::user()->orders()->save($order);
Session::forget('cart');
return redirect("home");
}
Please or to participate in this conversation.