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