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.
Comments (0)
No comments yet!