1.

How to get last inserted id using laravel query?

Answer»

In case you are using SAVE()

$BLOG = new Blog;
$blog->title = ‘Best Interview Questions’;
$blog->save()

// Now you can USE (after save() FUNCTION we can use like this)

$blog->ID // It will display last inserted id

In case you are using insertGetId()

$insertGetId = DB::table(‘blogs’)->insertGetId([‘title’ => ‘Best Interview Questions’]);



Discussion

No Comment Found