laravel update query – Laravel Eloquent Update Query Example

laravel update query – We can update the records using the DB facade with update method. To update the data in mysql table UPDATE statement is used. In this example i will learn about how to update a record or data from MySQL database using laravel framework PHP.

laravel update query – Update data from database using Laravel framework

Update data from database using Laravel framework – To update the data in mysql table UPDATE statement is used.

UPDATE table_name
SET column1=value, column2=value2,...
WHERE some_column=some_value 

laravel update from query
The syntax of update method is as shown in the following code.

$affected = DB::table('Products')
              ->where('id', 1)
              ->update(['pcode' => 4554]);

laravel where update query

DB::table('Products')
        ->where('id', $id)
        ->update([
            'status'     => 1
        ]);

eloquent update row response

DB::table('Products')
            ->where('id', 1)
            ->update(['product_order' => 8]);

laravel db::query update

 DB::table('Product')->where('email', $ProductEmail)->update(array('product_type' => 'simple'));  

Laravel eloquent update

use App\Models\Product;

$product = Product::find(1);

$product->name = 'Lenova z570';

$product->save();

update query in laravel eloquent

use App\Models\Product;

$Product_Update = Product::where("id", '2')->update(["product_type" => 'simple']);

Don’t Miss : Laravel 6 Update Query Using Eloquent Example

Laravel Eloquent Update Query Example

Laravel Update Query Without Use Model

DB::table('products')->where('id', 1)->update([
'pcode' => 'p360125'
]);

Laravel Update Query Using Model

Product::where('id', 1)->update([
'pcode' => 'p360125'
]);

I hope you get an idea about laravel update query.
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