master
parent
862fb3ac9a
commit
02f2ac76f5
@ -0,0 +1,39 @@
|
||||
<?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,
|
||||
"客户姓名" => $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);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue