parents = $parents; $this->service = new ParkingOccupancyRateService( new OperationLogService() ); $this->parkingSpaceType = ParkingSpaceType::getData(); } public function array(): array { $data = []; $index = 1; $parkingSpaceType = $this->parkingSpaceType; $query = $this->service->queryList($this->parents); $list = $query->select()->get()->toArray(); foreach ($list as $item) { $item = $this->service->getItem($item, $parkingSpaceType); $value = [ 'index' => $index, 'time' => $item['time'], 'floor' => $item['floor'] ]; foreach ($parkingSpaceType as $type) { $type_id = $type['id']; $key = 'type' . $type_id; $value[$key] = $item[$key]; } $data[] = $value; $index += 1; } return $data; } /** * @return array */ public function headings(): array { $header = [ __('exports.global.index'), __('exports.occupancy_rate.time'), __('exports.occupancy_rate.floor'), ]; foreach ($this->parkingSpaceType as $value) { $header[] = $value['name']; } return $header; } }