last insert id laravel 8 code example
Example 1: return last inserted id in laravel
$id = DB::table('users')->insertGetId([
'email' => '[email protected]',
'votes' => 0
]);
Example 2: laravel query builder get last insert id
$id = DB::table('users')->insertGetId(
['email' => '[email protected]', 'votes' => 0]
);