Answer the question
In order to leave comments, you need to log in
How to get the id of the newly added order to the database?
All with the upcoming!
I add an order to the database and I need to get the id value of the newly added order and add it to several other tables
. I use this method:
public function modalSend(request $request){
$siteID = Cache::get('/' . $request->getHttpHost())->id;
if ($request->setting != null){$settings_id = $request->settings;}else{$settings_id = null;}
if ($request->setting != null){$category_id = $request->category;}else{$category_id = null;}
if ($request->setting != null){$product_id = $request->product;}else{$product_id = null;}
Orders::insert(['siteID' => $siteID, 'settings_id' => $settings_id, 'category_id' => $category_id, 'product_id' => $product_id, 'tel' => $request->tel, 'email' => $request->email, 'created_at' => date('Y-m-d H:i:s')]);
// тут мне надо достать id только что добавленного в таблицу Orders заказа и записать его в другие таблицы
// Order_message::insert...
// Order_customer::insert...
// Order_tag::insert...
// Order_goods::insert...
return redirect()->back()->with('success', '1');
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question