If you want to create multiple records at time using laravel eloquent, then you can do it using "insert()" of laravel eloquent. insert() will provide to bulk insert records. insert() take array argument. You can simply give array then it will create single rows of table, if you pass multi dimensional array, then will create multiple records.
Here, you can learn to insert several records at time, as bellow i give you syntax of insert().
Syntax:
DB::table('yourTableName')
->insert(array(
array(...),
array(...),
array(...),
.....
));
As above syntax, you can see how to pass multiple records for insert, So, let's see bellow example.
Example:
DB::table('items')
->insert(array(
array('title'=>'Test', 'description'=>'Test Description'),
array('title'=>'Test 2', 'description'=>'Test Description 2'),
array('title'=>'Test 3', 'description'=>'Test Description 3'),
));
If you want to insert multiple records then it can help you...
Do you like below Tutorials ?
- How to Open URL in New Tab using Jquery?
- Laravel 7.x and 6.x Routing Tutorial
- Ng Bootstrap Modal in Angular 8 Example
- Bootstrap 4 Datepicker in Angular 9/8 Example
- Disable Registration Route in Laravel
- Bootstrap Timepicker in Angular Example
- Count Number of Pages in PDF - PHP Script
- Digital Signature PHP Script Example