Increment value of multiple columns at once in Laravel

1 · Amit Merchant · Jan. 22, 2023, 6:38 p.m.
Laravel comes with handy little utilities when you want to increment or decrement the value of a column in a database table. The incrementEach method The decrementEach method For instance, you can use the increment method to increment the value of a column by a given amount. $user = DB::table('users')->find(1); // increment the value of the `posts_count` column by 1 $user->increment('posts_count'); // increment the value of the `posts_count` column by 5 $user->increment('posts_count', 5); S...