From 4121c3afb4cc1aee20cfd1353c36389ee0e63d8a Mon Sep 17 00:00:00 2001 From: "sosuke.iwabuchi" Date: Tue, 31 Oct 2023 15:49:30 +0900 Subject: [PATCH] =?UTF-8?q?=E5=90=84=E7=A8=AE=E7=94=B3=E8=AB=8B=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E3=81=AE=E6=95=B4=E5=82=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SeasonTicketContractPlan/VehicleType.php | 28 +++++++++++ app/Kintone/Models/SeasonTicketContract.php | 46 +++++++++++++++++-- 2 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 app/Kintone/Models/DropDown/SeasonTicketContractPlan/VehicleType.php 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(); + } }