Laravel 6 insert or update multiple records

Today, We want to share with you Laravel 6 insert or update multiple records.In this post we will show you Laravel db insert multiple data, hear for Laravel update multiple rows with different values we will give you demo and example for implement.In this post, we will learn about how to update query in laravel with an example.

Laravel 6 insert or update multiple records

There are the Following The simple About Allow Eloquent to save multiple records at once Full Information With Example and source code.

As I will cover this Post with live Working example to develop Insert Update and Delete record from MySQL in Laravel, so the laravel update multiple rows in one query is used for this example is following below.

How to insert multiple records in Laravel 6?

$myMovies = [
            ['title'=>'SPG Group','description'=>'Saradar patel Group digital'],
            ['title'=>'SPG Group 2','description'=>'Saradar patel Group main 2'],
            ['title'=>'SPG Group 3','description'=>'Saradar patel Group last 3']
        ];
DB::table("movies")->insert($myMovies);

Example 2

Update multiple records using Eloquent

Movie::where('movi_type_id', '=', 1)
->update(['name' => 'bahubali 4']);

//or

Movie::where('movi_type_id', '=', 1)->update(['name' => 'dabang']);

Example 3

laravel insert/update multiple rows in one query

$product_varible = array("id"=>'1',"name"=>"tamilrokers","details"=>"free download movies");
$product_sample = array("id"=>'2',"name"=>"jioRokers","details"=>"upcomming new movies");
DB::table('products')->insert(array($product_varible,$product_sample));
Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about laravel 6.2 eloquent insert multiple rows.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment