get last id of table in laravel code example
Example 1: laravel get last record
Model::latest()->first();
Example 2: return last inserted id in laravel
$id = DB::table('users')->insertGetId([
'email' => '[email protected]',
'votes' => 0
]);
Example 3: laravel get last record
return DB::table('files')->order_by('upload_time', 'desc')->first();
Example 4: return last inserted id in laravel
DB::getPdo()->lastInsertId();