laravel insert get last id code example
Example 1: Get last id in laravel
$last2 = DB::table('items')->orderBy('id', 'DESC')->first();
Example 2: laravel get ID from insert
$data = User::create(['name'=>'first']);
dd($data->id);
$last2 = DB::table('items')->orderBy('id', 'DESC')->first();
$data = User::create(['name'=>'first']);
dd($data->id);