increment自增方法有两个参数:第一个参数 必填 代表数据库中那个字段自增,第二个参数 选填 如果为空则表示每次递增 加 1
如果填写了比如3,则表示每次在原有的基础上递增 加3
decrement自减方法同上
- DB操作:
DB::table('users')->increment('votes');
DB::table('users')->increment('votes', 5);
DB::table('users')->decrement('votes');
DB::table('users')->decrement('votes', 5);
- 模型操作
Pattern::where('id',$id)->increment('download');