I'm using Laravel 5.4.
I'm creating a very basic store app. Whereby, you can select products, add them to a basket, and either continue shopping or checkout.
I have a stage called "Order Setup" where logged in users define certain parameters, this then gets stored into session with the object order. e.g.:
$order = new Order();
$order->company_id = $data['company_id'];
$order->customer_id = $data['customer_id'];
$order->delivery_address_id = $data['delivery_address_id'];
$order->total_cost = 0.0;
$order->limit_remaining = $limitRemaining;
$order->delivery_cost = $customer->delivery_cost;
$order->minShipDate = $customer->minDespatchDate();
$order->deliveryOptions = DeliveryOptions::where('deleted', 0)->pluck('name', 'id');
$request->session()->put('order', $order);
At a later point, when a user adds an item to the "order" object above, i want to create a child object of the parent "order" above. e.g. of building the object below, but what's the best way to append this in session, whilst maintaining a relationship?
$orderDetail = new OrderDetail();
$orderDetail->stock_code = $orderItem['stock_code'];
$orderDetail->quantity = floatval($orderItem['quantity']);
$orderDetail->cost = floatval($productSetup->price);
$orderDetail->line_price = $productSetup->price * $orderItem['quantity'];
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire