laravel

The Complete Guide to Incrementing Multiple Column Values

The-Complete-Guide-to-Incrementing-Multiple-Column-Values.png

The art of Increment and the decrement of multiple column values are most useable. As we know before Laravel version 9.48.0 we can only increment single-column values but after releasing Laravel version 9.48.0 we are able to increment multiple-column values. This article provides you with a complete guide to increment multiple column values step-by-step.

Laravel's new version introduces the incrementEach and decrementEach. You use these methods to increase and decrease the multiple-column values. In this article, we will see both methods with worked examples.

The Complete Guide to Incrementing Multiple Column Values

The Multiple Values Increment example:

DB::table('traffic')->where('slug', 'crud-system-in-laravel')->incrementEach([
     'visit' => 1,
     'cost' => 5,
]);

The Multiple Values Decrement example:

DB::table('traffic')->where('slug', 'crud-system-in-laravel')->decrementEach([
     'visit' => 1,
     'cost' => 5,
]);

Thank You for reading this article. I hope it is helpful to you.

 

 



About author

IMG_8897.png

Muhammad Zubair

My name is Muhammad Zubair. I'm a full-stack developer. I'm a owner of theskillstock.com. I love to write tutorials of PHP, Laravel, Html & css, Javascript, Java and much more with examples.


Comments

No Comments Yet.



Leave a Reply