My PostOrder Function
public function getPaymentStatus(Request $request){
if ($result->getState() == 'approved') {
$user_id = Auth::user()->id;
$user_email = Auth::user()->email;
//get shipping details
$shippingDetails = DeliveryAddress::where(['user_email'=>$user_email])->first();
$order = new Order;
$order->user_id = $user_id;
$order->user_email = $user_email;
$order->name = $shippingDetails->name;
$order->address = $shippingDetails->address;
$order->city = $shippingDetails->city;
$order->state = $shippingDetails->state;
$order->country = $shippingDetails->country;
$order->postcode = $shippingDetails->postcode;
$order->mobile = $shippingDetails->mobile;
$order->coupon_code = $coupon_code;
$order->coupon_amount = $coupon_amount;
$order->order_status = "New";
$order->grand_total = Session::get('grand_total');
$order->save();
$order_id = DB::getPdo()->lastInsertId();
$cartProducts = DB::table('cart')->where(['user_email'=>$user_email])->get();
foreach($cartProducts as $pro){
$cartPro = new OrdersProduct;
$cartPro->order_id = $order_id;
$cartPro->user_id = $user_id;
$cartPro->product_id = $pro->product_id;
$cartPro->product_code = $pro->product_code;
$cartPro->product_name = $pro->product_name;
$cartPro->product_size = $pro->size;
$cartPro->product_color = $pro->product_color;
$cartPro->product_price = $pro->price;
$cartPro->product_qty = $pro->quantity;
$cartPro->save();
}
return redirect('/thank-you');
}
i have a table "products" which store product details and a table "products_attribute" which store the stock of the product. I don't know how link this to products_attribute table. Please Help.