停车场管理系统
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.
 
 

62 lines
1.8 KiB

<?php
namespace App\Exports;
use App\Models\AdminNotice;
use App\Services\AdminNoticeService;
use App\Services\OperationLogService;
use Maatwebsite\Excel\Concerns\FromArray;
use Maatwebsite\Excel\Concerns\WithHeadings;
class AdminNoticeExport implements FromArray, WithHeadings
{
public function array(): array
{
$data = [];
$index = 1;
$columns = [
'alarm_time',
'alarm_type',
'camera_ip',
'msg_type',
'space_id',
'msg_content'
];
AdminNotice::all($columns)->each(
function ($item) use (&$data, &$index) {
$oldItem = (new AdminNoticeService(
new OperationLogService()
))->getItem($item);
$data[] = [
'id' => $index,
'alarm_time' => $oldItem['alarm_time'],
'alarm_type' => $oldItem['alarm_type'],
'msg_type' => $oldItem['msg_type'],
'space_number' => $oldItem['parking_space_number'],
'license_plate' => $oldItem['license_plate'],
'camera_ip' => $oldItem['camera_ip'],
'msg_content' => $oldItem['msg_content']
];
$index += 1;
}
);
return $data;
}
/**
* @return array
*/
public function headings(): array
{
return [
__('exports.global.index'),
__('exports.notice.alarm_time'),
__('exports.notice.alarm_type'),
__('exports.notice.msg_type'),
__('exports.notice.space_number'),
__('exports.notice.license_plate'),
__('exports.notice.camera_ip'),
__('exports.notice.msg_content')
];
}
}