多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
``` Db::whereTime('time','today')->select() //获取今天的数据 ``` ``` Db::whereTime('time','yesterday')->select() //获取昨天的数据 ``` ``` Db::whereTime('time','week')->select() //获取本周的数据 ``` ``` Db::whereTime('time','last week')->select() //获取上一周的数据 ``` ``` Db::whereTime('time','month')->select() //获取本月的数据 ``` ``` Db::whereTime('time','year')->select() //获取今年的数据 ``` ``` Db::whereTime('time','last year')->select() //获取去年的数据 ``` ## 模型批量更新** ~~~ $addressList::where('user_id',$uid)->update(['default'=>0]); ~~~ ## **日志写入自定义路径** ``` Log::init(['type' => 'File', 'path' => LOG_PATH . 'commission/']); log::write($this->request->post(),'info'); ``` ## 模型自动格式化时间戳 ~~~ // 定义时间戳字段名 protected $createTime = 'createtime'; protected $updateTime = 'updatetime'; protected $dateFormat = 'Y-m-d H:i:s'; ~~~ 模型关联查询使用关联模型作为查询条件 ~~~ $data = $this->with(['user', 'order', 'dealerFirst', 'dealerSecond', 'referee' => function ($q) use ($dealer_id) { $q->where('dealer_id', $dealer_id); }])->where($where) ->where('first_user_id|second_user_id', '=', $dealer_id) ->order(['create_time' => 'desc']) ->select(); ~~~