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
62 lines
1.8 KiB
<?php
|
|
|
|
namespace App\Exports;
|
|
|
|
use App\Services\OperationLogService;
|
|
use App\Services\UtilizationRateService;
|
|
use Maatwebsite\Excel\Concerns\FromArray;
|
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
|
|
class UtilizationRateExport implements FromArray, WithHeadings
|
|
{
|
|
public array $parents = [];
|
|
public UtilizationRateService $service;
|
|
|
|
public function __construct($parents)
|
|
{
|
|
$this->parents = $parents;
|
|
$this->service = new UtilizationRateService(
|
|
new OperationLogService()
|
|
);
|
|
}
|
|
|
|
public function array(): array
|
|
{
|
|
$data = [];
|
|
$index = 1;
|
|
$query = $this->service->searchQuery($this->parents);
|
|
$list = $query->select()->get()->toArray();
|
|
foreach ($list as $item) {
|
|
$item = $this->service->getItem($item);
|
|
$data[] = [
|
|
'index' => $index,
|
|
'start_time' => $item['start_time'],
|
|
'end_time' => $item['end_time'],
|
|
'floor' => $item['floor'],
|
|
'number' => $item['number'],
|
|
'space_type' => $item['space_type'],
|
|
'space_attr' => $item['space_attr'],
|
|
'rate' => $item['rate']
|
|
];
|
|
$index += 1;
|
|
}
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function headings(): array
|
|
{
|
|
return [
|
|
__('exports.global.index'),
|
|
__('exports.event_calendar.export3'),
|
|
__('exports.event_calendar.export5'),
|
|
__('exports.parking_space.floor'),
|
|
__('exports.parking_space.number'),
|
|
__('exports.parking_space.space_type'),
|
|
__('exports.parking_space.space_attr'),
|
|
__('exports.utilization_rate.rate'),
|
|
];
|
|
}
|
|
}
|
|
|