how to get last inserted id in laravel
// how to get last inserted id in laravel
//METHOD-1
$data->save();
$lastId = $data->id;
//METHOD-2
$data = Booking::latest('id')->first();
$id = data->id;
how to get last inserted id in laravel
// how to get last inserted id in laravel
//METHOD-1
$data->save();
$lastId = $data->id;
//METHOD-2
$data = Booking::latest('id')->first();
$id = data->id;
return last inserted id in laravel
$id = DB::table('users')->insertGetId([
'email' => '[email protected]',
'votes' => 0
]);
laravel db insert get last id
$id = DB::table('users')
->insertGetId(
['name' => 'Akash Savani', 'email'=>'[email protected]']
);
laravel get ID from insert
$data = User::create(['name'=>'first']);
dd($data->id);
laravel model save get id
$data->save();
$data->id;
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us