data = $data; } public function headings(): array { return [ 'id', '姓名', '昵称', '手机', '性别', '年龄', '学历', '行业', '信仰', '常居地', '情感状态', '收入', ]; } //设置列格式 public function columnFormats(): array { return [ 'A' => NumberFormat::FORMAT_TEXT, 'D' => NumberFormat::FORMAT_TEXT, ]; } public function collection() { $data = []; foreach($this->data as $row) { switch($row["sex"]) { case 1: $sex = "男"; break; case 2: $sex = "女"; break; default: $sex = "未知"; } $data[] = [ $row["user_id"], $row["name"], $row["nickname"], $row["mobile"], $sex, $row["age"], $row["degree"], $row["industry"]."/".$row["industry_sub"], $row["belief"], $row["province"]."-".$row["city"], $row['state'], $row["income"] ]; } $data = collect($data); return $data; } }