You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.3 KiB

<?php
namespace App\Exports;
use App\Models\Paramedic;
use Maatwebsite\Excel\Concerns\FromCollection;
class OrdersExport implements FromCollection
{
public function __construct($data)
{
$this->data = $data;
}
/**
* @return \Illuminate\Support\Collection
*/
public function collection()
{
$res = [];
foreach ($this->data as $row) {
$res[] = [
"订单编号" => " ".$row->serial,
"所属项目/医院" => $row->project->name,
"楼栋" => isset($row->bed->building) ? $row->bed->building->name : "",
"楼层/病区" => isset($row->bed->area) ? $row->bed->area->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);
}
}