['mobile'], '%like%' => ['real_name'] ]; } public function queryWhere(){ $where[] = ['type','=',2]; return $where; } /** * @notes 获取列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function lists(): array { $list = MasterWorker::with(['stopList'])->where($this->searchWhere) ->where($this->queryWhere()) ->field(['id','real_name','mobile','avatar']) ->limit($this->limitOffset, $this->limitLength) ->order("id","desc") ->select() ->toArray(); foreach ($list as &$item) { $stopList = []; foreach( $item['stopList'] as $v ) { $min = (int)date("d",strtotime($v['start_time'])); $max = (int)date("d",strtotime($v['end_time'])); $stopList = array_merge($stopList,range($min,$max)); } $item['stopList'] = array_values(array_unique($stopList)); } return $list; } /** * @notes 获取数量 * @return int * @author likeadmin * @date 2024/07/10 18:17 */ public function count(): int { return MasterWorker::where($this->searchWhere) ->where($this->queryWhere()) ->count(); } }