data = $data; } /** * @return \Illuminate\Support\Collection */ public function collection() { $res = []; foreach ($this->data as $row) { $res[] = [ "订单编号" => " ".$row->serial, "所属项目/医院" => $row->project->name, "科室" => $row->department, "客户姓名" => $row->customer->name ?: $row->patient->name, "联系电话" => " ".$row->customer->mobile, "被护理人" => $row->patient->name, "开始服务日期" => $row->from_date, "结束服务日期" => $row->to_date, "总计" => $row->total, "状态" => $row->getStatusLabelAttribute(), ]; } if (count($res)) { array_unshift($res, array_keys($res[0])); } return collect($res); } }