How to get last inserted id in Laravel?
Use insertGetId()
$id = DB::table('users')-> insertGetId(array(
'email_id' => $email_id,
'name' => $name,
));
Follow the code to get last inserted id by using ->insert()
$lastInsertedID = DB::table('users')
->insert( array(
'email_id' => $email_id,
'name' => $name
)
)
->lastInsertId();