|
|
@@ -2,9 +2,9 @@ |
|
|
|
|
|
|
|
|
namespace App\Kintone\Models; |
|
|
namespace App\Kintone\Models; |
|
|
|
|
|
|
|
|
|
|
|
use App\Kintone\Models\DropDown\SeasonTicketContractPlan\VehicleType; |
|
|
use App\Util\DateUtil; |
|
|
use App\Util\DateUtil; |
|
|
use Illuminate\Support\Carbon; |
|
|
use Illuminate\Support\Carbon; |
|
|
use LogicException; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* アプリ名 車室情報管理 |
|
|
* アプリ名 車室情報管理 |
|
|
@@ -73,21 +73,41 @@ class SeasonTicketContract extends KintoneModel |
|
|
self::FIELD_OTHER_LICENSE_IMAGES_UPLOAD_DATETIME => 'other_license_images_upload_datetime', |
|
|
self::FIELD_OTHER_LICENSE_IMAGES_UPLOAD_DATETIME => 'other_license_images_upload_datetime', |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
private ?SeasonTicketContractPlan $plan = null; |
|
|
|
|
|
private ?Parking $parking = null; |
|
|
|
|
|
private ?Customer $customer = null; |
|
|
|
|
|
|
|
|
protected function toArrayCustom(): array |
|
|
protected function toArrayCustom(): array |
|
|
{ |
|
|
{ |
|
|
return [ |
|
|
return [ |
|
|
'can_some_apply' => $this->canSomeApply(), |
|
|
'can_some_apply' => $this->canSomeApply(), |
|
|
|
|
|
'can_parking_certificate_apply' => $this->canParkingCertificateApply(), |
|
|
|
|
|
'can_change_plan_apply' => $this->canChangePlanApply(), |
|
|
]; |
|
|
]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function getParking(): Parking |
|
|
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 |
|
|
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; |
|
|
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(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |