ソースを参照

各種申請条件の整備

master
sosuke.iwabuchi 2年前
コミット
4121c3afb4
2個のファイルの変更71行の追加3行の削除
  1. +28
    -0
      app/Kintone/Models/DropDown/SeasonTicketContractPlan/VehicleType.php
  2. +43
    -3
      app/Kintone/Models/SeasonTicketContract.php

+ 28
- 0
app/Kintone/Models/DropDown/SeasonTicketContractPlan/VehicleType.php ファイルの表示

@@ -0,0 +1,28 @@
<?php

namespace App\Kintone\Models\DropDown\SeasonTicketContractPlan;

abstract class VehicleType
{
const V1_普通車 = "普通車";
const V2_軽自動車 = "軽自動車";
const V3_大型自動車 = "大型自動車";
const V4_中型車 = "中型車";
const V5_自転車 = "自転車";
const V6_原付 = "原付";
const V7_バイク = "バイク";
const V8_小型バイク = "小型バイク";
const V9_中型バイク = "中型バイク";
const V10_大型バイク = "大型バイク";
const V11_小型中型バイク = "小型中型バイク";
const V12_中型大型バイク = "中型大型バイク";
const V13_ナイトカード = "ナイトカード";
const V14_普通車_1割引 = "普通車_1割引";
const V15_軽自動車_1割引 = "軽自動車_1割引";
const V16_中型車_1割引 = "中型車_1割引";
const V17_大型自動車_1割引 = "大型自動車_1割引";
const V18_普通車_特別割 = "普通車_特別割";
const V19_軽自動車_特別割 = "軽自動車_特別割";
const V20_中型車_特別割 = "中型車_特別割";
const V21_大型自動車_特別割 = "大型自動車_特別割";
}

+ 43
- 3
app/Kintone/Models/SeasonTicketContract.php ファイルの表示

@@ -2,9 +2,9 @@

namespace App\Kintone\Models;

use App\Kintone\Models\DropDown\SeasonTicketContractPlan\VehicleType;
use App\Util\DateUtil;
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',
];

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();
}
}

読み込み中…
キャンセル
保存