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 Display Data in Angular 10?
- Angular 10 Routing Module Example Tutorial
- Angular 10 CRUD Operations with Web API Example
- Laravel 8 CRUD Operation Step By Step Tutorial
- Solved - Target class [ProductController] does not exist in Laravel 8
- Step by Step Form Validation in Laravel 8 Example
- Laravel 8 Image Upload with Preview Example
- Laravel 8 Multiple Images Upload with Preview Example