DB Query Builder
Using the DB query builder it would look like below.
DB::table('posts')->increment('count'); DB::table('posts')->increment('count', 10); DB::table('posts')->decrement('count'); DB::table('posts')->decrement('count', 10);
Laravel Eloquent
The other way is by using the eloquent model.
Post::find(1)->increment('count'); Post::find(1)->increment('count', 10); Post::find(1)->decrement('count'); Post::find(1)->decrement('count', 10);
Leave a reply