I am new to laravel and try to add record in db. record is successfully inserted but now i need to getLast inserted id.
Insert record array here:
User::insert(
[
'first_name' => $data->first_name,
'last_name' => $data->last_name,
'email' => $data->signup_email,
'contact' => $data->signup_contact,
'role_id' => $data->role_id,
'password' => bcrypt($data->password_contact),
'confirm_passsword'=>bcrypt($data->confirmpassword_contact),
'created_at' => date('Y-m-d'),
'updated_at' => date('Y-m-d'),
]
);
Thanks to all for any help.
Just replace "insert" with "insertGetId". Thats it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.