How to get the last insert id in laravel query builder.

  • Neel Bhardwaj

  • 07-Feb-2022


  • 156

$id = DB::table('table-name')->insertGetId(
    ['name' => 'abc', 'email' => '']

"Programming isn't about what you know,
it's about what you can figure out.”
Chris Pine

Neel Bhardwaj

A full stack developer. I have a Passion for Creating Clean, Beautiful, Interactive, Minimalistic, Responsive and User Friendly website, Developed by Modular, Scalable and Functional Code.

Recent comments

Leave a reply

Fatal error: Cannot declare class Connection, because the name is already in use in /home/d8ouyzxnuef4/public_html/ on line 3