Answers for "how to get last inserted row in laravel"

PHP
3

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;
Posted by: Guest on March-05-2021
6

laravel get last record

Model::latest()->first();
Posted by: Guest on May-06-2020
0

laravel get last record

return DB::table('files')->order_by('upload_time', 'desc')->first();
Posted by: Guest on May-26-2020
0

laravel db insert get last id

$id = DB::table('users')

  ->insertGetId(

	  ['name' => 'Akash Savani', 'email'=>'[email protected]']

);
Posted by: Guest on June-29-2020

Code answers related to "how to get last inserted row in laravel"

Browse Popular Code Answers by Language