Increment & Decrement in Laravel 5

If you want to increment or decrement opration using update() method of laravel query builder then you also do that, i am showing you how to increment and decrement value of column in table by using increment(), and decrement().

Both of these methods accept at least one argument the column to modify. A second argument may optionally.

DB::table('tbl_order')->increment('amount');
DB::table('tbl_order')->increment('amount', 150);
DB::table('tbl_order')->decrement('amount');
DB::table('tbl_order')->decrement('amount', 200);

You may also specify additional columns to update during the operation using array

DB::table('tbl_order')->increment('amount', 120, ['product_name' => 'ball']);

Leave a Reply

Your email address will not be published. Required fields are marked *