How to insert multiple records in Laravel 5?By Hardik Savani | June 13, 2016 | | 3182 Viewer | Category : Laravel
Share this post:
If we work on big project and then we maybe require to add multiple rows on database using laravel eloquent. Laravel provide insert method for bulk records create on db.
In bellow example you can see i use multidimensional $myItems array variable and that insert multiple records same time using DB::insert(). So let's see and try this.
$myItems = [
['title'=>'HD Topi','description'=>'It solution stuff'],
['title'=>'HD Topi 2','description'=>'It solution stuff 2'],
['title'=>'HD Topi 3','description'=>'It solution stuff 3']
- How to group by multiple columns in Laravel Query Builder?
- Laravel 5 - multiple files download with response example
- Laravel 5.2 multi auth example using Auth guard from scratch
- Laravel 5 - inner join with multiple conditions example using Query Builder
- Order by using multiple columns and manually array field in Laravel?
- How to check table is exists or not in Laravel 5?
- How to get year, month and day from timestamp date using carbon in Laravel 5?
- Laravel 5 - Dynamic Dependant Select Box using JQuery Ajax Example - Part 1
- Display preview selected image in input type file using JQuery
- How to remove empty values from array in PHP?
- How to add CKEditor with image upload using KCFinder in PHP Example Code?
- How to increment or decrement a column value in laravel?
- JQuery - Delete confirm modal using bootbox example