['name'] ]; } /** * @notes 列表 * @return array * @author cjhao * @date 2021/7/28 18:48 */ public function lists(): array { $lists = UserLabel::field('id,name,label_type') ->where($this->searchWhere) ->limit($this->limitOffset, $this->limitLength) ->order('id', 'desc') ->select() ->toArray(); $labelCount = UserLabelIndex::group('label_id')->column('count(id) as num', 'label_id'); foreach ($lists as $key => $label) { $lists[$key]['num'] = $labelCount[$label['id']] ?? 0; } return $lists; } /** * @notes 搜索条数 * @return int * @author cjhao * @date 2021/7/28 18:48 */ public function count(): int { return UserLabel::where($this->searchWhere)->count(); } /** * @notes 设置excel表名 * @return string * @author cjhao * @date 2021/9/23 17:05 */ public function setFileName(): string { return '用户标签'; } /** * @notes 设置导出字段 * @return array * @author cjhao * @date 2021/9/23 17:07 */ public function setExcelFields(): array { return [ 'name' => '标签名称', 'num' => '用户数', ]; } }