customerCode = $customerCode; $this->parkingManagementCode = $parkingManagementCode; } public function init(string $host = null, int $port = null, string $path = null) { if ($host === null || $port === null || $path === null) { $this->setModels(); } $this->setHost($host); $this->setPort($port); $this->setPath($path); $this->already_init = true; } public function send(IFRequest $request): Response { if (!$this->already_init) { $this->init(); } $now = Carbon::now(); $request->header->customerCode = $this->customerCode; $request->header->parkingManagementCode = $this->parkingManagementCode; $request->header->resultCode = ResultCode::SUCCESS->value; $request->header->sendDatetime = $now->format('YmdHis'); $data = $request->toArray(); $url = $this->getUrl(); info('SEND ' . $request->header->interfaceId, [$data, $url]); $this->response = Http::post($url, $data); return $this->response; } private function setModels(): void { $this->customer = MstCustomer::customerCode($this->customerCode)->firstOrFail(); $this->system = SmstServerSystem::firstOrFail(); TblPark::setCustomerId($this->customer->id); $this->park = TblPark::parkingManagementCode($this->parkingManagementCode)->firstOrFail(); $this->adjuster = TblAdjuster::isUpdateMachine($this->park->id) ->firstOrFail(); } private function setHost(string|null $host): void { if ($host !== null) { $this->host = $host; } else { $this->host = $this->adjuster->adjuster_ipaddress; } } private function setPort(int|null $port): void { if ($port !== null) { $this->port = $port; } else { $this->port = $this->system->port_number_season_ticket_update; } } private function setPath(string|null $path): void { if ($path !== null) { $this->path = $path; } else { // デフォルト値のまま } } public function getUrl(): string { return 'http://' . $this->host . ':' . $this->port . '/' . $this->path; } }