roleAllow(UserRole::NORMAL_ADMIN); } protected function getParam(): IParam { return $this->param; } protected function run(Request $request): BinaryFileResponse { $param = $this->param; $condition = [ ...$param->toArray(), Repository::CONDITION_CONTRACT_ID => $this->loginUser()->getCurrentContractId(), Repository::CONDITION_SORT_TARGET => 'customer_code', ]; $list = $this->repository->forCsv()->get($condition); // $csv = new CsvFile($this->getHeaderLabel(), CsvFile::ENCODE_SJIS); $csv = new CsvFile($this->getHeaderLabel()); foreach ($list as $row) { $csv->addLine($row->toArray()); } return $csv->download($this->getDownloadFileName()); } private function getHeaderLabel(): array { $headers = [ '集計ID', '集計年月', '顧客コード', '顧客名', '駐車場管理コード', '駐車場名', '領収証発行依頼件数', '郵送依頼件数', 'SMS送信件数', ]; return $headers; } private function getDownloadFileName() { return sprintf("利用実績_%s.csv", $this->param->summaryYyyymm); } }