|
- <?php
-
- namespace App\Kintone\Models;
-
- use App\Kintone\Models\SubTable\SeasonTicketContractPlan\CanChangePlanName;
- use Illuminate\Support\Collection;
-
- /**
- * アプリ名 定期駐車場プランマスタ
- * @property string planName
- * @property string showPlanName
- * @property string parkingName
- * @property string[] sendItem
- * @property string vehicleType
- * @property ?int amount
- * @property ?int taxAmount
- * @property ?int taxRate
- * @property Collection<int ,CanChangePlanName> canChangePlanNameList
- * @property ?int deposit
- * @property ?int chainGateDeposit
- * @property ?int cardDeposit
- * @property ?int totalDeposit
- * @property string[] canPayByCreditcard
- */
- class SeasonTicketContractPlan extends KintoneModel
- {
- const CONFIG_KEY = "KINTONE_APP_SEASON_TICKET_CONTRACT_PLAN";
-
- const FIELD_PLAN_NAME = "key";
- const FIELD_SHOW_PLAN_NAME = "利用者へ表示するプラン名";
- const FIELD_PARKING_NAME = "定期_駐車場名";
- const FIELD_SEND_ITEM = "送付物";
- const FIELD_VEHICLE_TYPE = "種別";
- const FIELD_AMOUNT = "契約金額";
- const FIELD_TAX_AMOUNT = "内税";
- const FIELD_TAX_RATE = "税率";
- const FIELD_DEPOSIT = "保証金";
- const FIELD_CHAIN_GATE_DEPOSIT = "チェーンゲート保証金";
- const FIELD_CARD_DEPOSIT = "パスカード保証金";
- const FIELD_TOTAL_DEPOSIT = "保証金合計額";
- const FIELD_CAN_PAY_BY_CREDITCARD = "クレジットカード支払許可";
-
- const FIELD_CAN_CHANGE_PLAN_NAME_LIST = "プラン変更申請にて変更可能なプラン一覧";
- const FIELD_CAN_CHANGE_PLAN_NAME_LIST_PLAN_NAME = "プラン変更申請にて変更可能なプラン一覧_定期_駐車場名_月額金額_駐車場備考_プラン_種別_支払パターン";
-
- protected const FIELDS = [
- ...parent::FIELDS,
- self::FIELD_PLAN_NAME => FieldType::SINGLE_LINE_TEXT,
- self::FIELD_SHOW_PLAN_NAME => FieldType::SINGLE_LINE_TEXT,
- self::FIELD_PARKING_NAME => FieldType::SINGLE_LINE_TEXT,
- self::FIELD_SEND_ITEM => FieldType::CHECK_BOX,
- self::FIELD_VEHICLE_TYPE => FieldType::SINGLE_LINE_TEXT,
- self::FIELD_AMOUNT => FieldType::NUMBER,
- self::FIELD_TAX_AMOUNT => FieldType::NUMBER,
- self::FIELD_TAX_RATE => FieldType::NUMBER,
- self::FIELD_CAN_CHANGE_PLAN_NAME_LIST => FieldType::SUBTABLE,
- self::FIELD_DEPOSIT => FieldType::NUMBER,
- self::FIELD_CHAIN_GATE_DEPOSIT => FieldType::NUMBER,
- self::FIELD_CAN_PAY_BY_CREDITCARD => FieldType::CHECK_BOX,
- self::FIELD_CARD_DEPOSIT => FieldType::NUMBER,
- self::FIELD_TOTAL_DEPOSIT => FieldType::NUMBER,
- ];
-
- protected const SUB_TABLES = [
- self::FIELD_CAN_CHANGE_PLAN_NAME_LIST => CanChangePlanName::class,
- ];
-
- protected const FIELD_NAMES = [
- ...parent::FIELD_NAMES,
- ];
-
- protected function toArrayCustom(): array
- {
- return [
- 'has_season_ticket' => $this->hasSeasonTicket(),
- 'has_sticker' => $this->hasSticker(),
- 'can_apply_change_plan' => $this->canApplyChangePlan(),
- ];
- }
-
- public static function findByName(string $name): static
- {
- return static::getAccess()->first(static::getQuery()->where(static::FIELD_PLAN_NAME, $name));
- }
-
- public function hasSeasonTicket(): bool
- {
- return in_array("定期券", $this->sendItem);
- }
- public function hasSticker(): bool
- {
- return in_array("シール", $this->sendItem);
- }
- public function canApplyChangePlan(): bool
- {
- return $this->canChangePlanNameList->isNotEmpty();
- }
- public function canPayByCreditcard(): bool
- {
- return in_array("許可", $this->canPayByCreditcard, true);
- }
- }
|