1// how to get last inserted id in laravel
2
3//METHOD-1
4$data->save();
5$lastId = $data->id;
6
7//METHOD-2
8$data = Booking::latest('id')->first();
9$id = data->id;
1$id = DB::table('users')->insertGetId([
2 'email' => 'john@example.com',
3 'votes' => 0
4]);
5
1$id = DB::table('users')->insertGetId(
2 ['email' => 'john@example.com', 'votes' => 0]
3);