data = $data; $this->index =$index; } public function headings(): array { return [ 'id', '姓名', '昵称', "手机号", '性别', '年龄', '学历', '省-市', '行业', '信仰', "情感状态", "收入" ]; } //设置列格式 public function columnFormats(): array { return [ 'A' => NumberFormat::FORMAT_TEXT, ]; } public function collection() { $arr = []; foreach ($this->data as $data) { if ($data->sex > 0 ) { $sex = $data->sex == 1?"男":"女"; }else { $sex ="未知"; } $age = CommonUtilsService::getAge($data->profileCourtship->birthday); $arr[] = [ $data->id, $data->name, $data->nickname, $data->mobile, $sex, $age, $data->profileCourtship->degree, $data->profileCourtship->province."-".$data->profileCourtship->city, $data->industry."/".$data->industry_sub, $data->profileCourtship->belief, $data->profileCourtship->state, $data->profileCourtship->income ]; } $arr = collect($arr); return $arr; } /** * @return string */ public function title(): string { return $this->index. "-用户列表"; } }