Laravel: get last Insert id from query builder
Try it once :-
$id = DB::getPdo()->lastInsertId();
According to laravel document
https://laravel.com/docs/5.8/queries#inserts
If the table has an auto-incrementing id, use the insertGetId method to insert a record and then retrieve the ID:
$id = DB::table('users')->insertGetId(
['email' => '[email protected]', 'votes' => 0]
);