get last inserted id just after insert in laravel code example
Example 1: laravel db insert get last id
$id = DB::table('users')
->insertGetId(
['name' => 'Akash Savani', 'email'=>'[email protected]']
);
Example 2: Get last id in laravel
$last2 = DB::table('items')->orderBy('id', 'DESC')->first();