Bladephp: Now with 7+ codeigniter, php, and laravel project 7+ php project From $18/Year From Rs. 1000/Year

How to find last insert id in Laravel 5

by
Category:laravel
mysql laravel
How to find last insert id in Laravel 5

If the table has an auto-incrementing id, use the insertGetId method to insert a record and then retrieve the ID. Many time user insert one record in table and find inserted id and this id insert another table.

$insert_id = DB::table('hold_history')->insertGetId(
    ['loat_no' => "GJHAEF", 
     'hold_for' => "alex",
     'on_hold_by' => '250',
     'status' => '1'
    ]
);

0 Comments


Html code work in comment box


Related Post