diff --git a/app/Kintone/Models/DropDown/SeasonTicketContractPlan/VehicleType.php b/app/Kintone/Models/DropDown/SeasonTicketContractPlan/VehicleType.php new file mode 100644 index 0000000..2d51a82 --- /dev/null +++ b/app/Kintone/Models/DropDown/SeasonTicketContractPlan/VehicleType.php @@ -0,0 +1,28 @@ + 'other_license_images_upload_datetime', ]; + private ?SeasonTicketContractPlan $plan = null; + private ?Parking $parking = null; + private ?Customer $customer = null; + protected function toArrayCustom(): array { return [ 'can_some_apply' => $this->canSomeApply(), + 'can_parking_certificate_apply' => $this->canParkingCertificateApply(), + 'can_change_plan_apply' => $this->canChangePlanApply(), ]; } public function getParking(): Parking { - return Parking::findByParkingName($this->parkingName); + if ($this->parking === null) { + $this->parking = Parking::findByParkingName($this->parkingName); + } + return $this->parking; } public function getCustomer(): Customer { - return Customer::findByCustomerCode($this->customerCode); + if ($this->customer === null) { + $this->customer = Customer::findByCustomerCode($this->customerCode); + } + return $this->customer; + } + + public function getPlan(): SeasonTicketContractPlan + { + if ($this->plan === null) { + $this->plan = SeasonTicketContractPlan::findByName($this->planName); + } + return $this->plan; } /** @@ -99,4 +119,24 @@ class SeasonTicketContract extends KintoneModel { return $this->contractEndDate instanceof Carbon ? DateUtil::now() <= $this->contractEndDate : false; } + + public function canParkingCertificateApply(): bool + { + return !in_array($this->getPlan()->vehicleType, [ + VehicleType::V5_自転車, + VehicleType::V6_原付, + VehicleType::V7_バイク, + VehicleType::V8_小型バイク, + VehicleType::V9_中型バイク, + VehicleType::V10_大型バイク, + VehicleType::V11_小型中型バイク, + VehicleType::V12_中型大型バイク, + VehicleType::V13_ナイトカード, + ]); + } + + public function canChangePlanApply(): bool + { + return $this->getPlan()->canChangePlanNameList->isNotEmpty(); + } }