I'm saving an order into my database, once the order is saved I want to grab that order ID to pull up the order information on the confirmation screen.
It's important that the most recent order id is the one that's just been saved. If two or more orders are placed at once how can you ensure the correct ID is retrieved. Is it possible that slow server response time could cause this to fail?
Currently, I've found you can do the following;
$order = new Orders([
'billing_name' => $request->input('billing-name'),
'billing_company' => $request->input('company-name'),
'billing_job_title' => $request->input('job-title'),
'billing_phone' => $request->input('billing-phone'),
'billing_email' => $request->input('billing-email'),
'billing_address_1' => $request->input('billing-address-1'),
'billing_address_2' => $request->input('billing-address-2'),
'billing_town' => $request->input('billing-town'),
'billing_county' => $request->input('billing-county'),
'billing_postcode' => $request->input('billing-postcode'),
'payment_status' => 'Pending',
]);
$order->save();
$recentOrder = $order->id;
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2oXmZhK
via IFTTT
Aucun commentaire:
Enregistrer un commentaire