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

68 lines
2.4 KiB

<?php
namespace App\Exports;
use App\Models\ParkingPatternSpace;
use App\Models\ParkingSpace;
use App\Services\EventCalendarService;
use App\Services\OperationLogService;
use App\Services\ParkingSpaceService;
use Maatwebsite\Excel\Concerns\FromArray;
use Maatwebsite\Excel\Concerns\WithHeadings;
class ParkingSpaceExport implements FromArray, WithHeadings
{
public function array(): array
{
$data = [];
$index = 1;
$query = ParkingSpace::query();
$pattern_id = EventCalendarService::getTargetModeId();
$spaceIds = ParkingPatternSpace::getParkingSpaceIds($pattern_id);
$query->whereIn('id', $spaceIds);
$query->select()->get()->each(
function ($item) use (&$data, &$index) {
$oldItem = (new ParkingSpaceService(
new OperationLogService()
))->optionItems($item);
$data[] = [
'id' => $index,
'parking_name' => $oldItem['parking_name'],
'floor' => $oldItem['floor'],
'number' => $oldItem['number'],
'space_attr' => $oldItem['space_attr'],
'license_plate' => $oldItem['license_plate'],
'berthing_time' => $oldItem['berthing_time'],
'recognition' => $oldItem['recognition'],
'status' => $oldItem['status'],
'space_type' => $oldItem['space_type'],
'operation_type' => $oldItem['operation_type'],
'updated_at' => $oldItem['updated_at']
];
$index += 1;
}
);
return $data;
}
/**
* @return array
*/
public function headings(): array
{
return [
__('exports.global.index'),
__('exports.parking_space.floor'),
__('exports.parking_space.number'),
__('exports.parking_space.space_attr'),
__('exports.parking_space.license_plate'),
__('exports.parking_space.berthing_time'),
__('exports.parking_space.recognition'),
__('exports.parking_space.status'),
__('exports.parking_space.space_type'),
__('exports.parking_space.operation_type'),
__('exports.parking_space.updated_at')
];
}
}