Today now in this post i will show you How to Insert Multiple Records in Laravel? When we are working with any big project . On that times we may be need to add the multiple rows on our database by using laravel eloquent. Here we know that laravel provide us insert method for the bulk records create on the db.
So now in the bellow example we can see that here i am using multidimensional array as name $myItems. On this array the variable and that will be insert with multiple records same time by using DB::insert().
So let’s start and try this.
$myItems = [ ['title'=>'Html','description'=>'codings point html'], ['title'=>'CSS','description'=>'codings point CSS'], ['title'=>'php','description'=>'codings point php'], ['title'=>'Laravel','description'=>'codings point laravel'] ]; DB::table("programmings")->insert($myItems);
Read Also : Laravel 8 Mobile Number Verification Tutorial
Thanks for read. I hope it help you. For more you can follow us on facebook