You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.7KB

  1. <?php
  2. namespace App\Kintone\Models;
  3. use App\Kintone\Models\SubTable\SeasonTicketContractPlan\CanChangePlanName;
  4. use Illuminate\Support\Collection;
  5. /**
  6. * アプリ名 定期駐車場プランマスタ
  7. * @property string planName
  8. * @property string showPlanName
  9. * @property string parkingName
  10. * @property string[] sendItem
  11. * @property string vehicleType
  12. * @property ?int taxAmount
  13. * @property ?int taxRate
  14. * @property Collection<int ,CanChangePlanName> canChangePlanNameList
  15. */
  16. class SeasonTicketContractPlan extends KintoneModel
  17. {
  18. const CONFIG_KEY = "KINTONE_APP_SEASON_TICKET_CONTRACT_PLAN";
  19. const FIELD_PLAN_NAME = "key";
  20. const FIELD_SHOW_PLAN_NAME = "利用者へ表示するプラン名";
  21. const FIELD_PARKING_NAME = "定期_駐車場名";
  22. const FIELD_SEND_ITEM = "送付物";
  23. const FIELD_VEHICLE_TYPE = "種別";
  24. const FIELD_TAX_AMOUNT = "内税";
  25. const FIELD_TAX_RATE = "税率";
  26. const FIELD_CAN_CHANGE_PLAN_NAME_LIST = "プラン変更申請にて変更可能なプラン一覧";
  27. const FIELD_CAN_CHANGE_PLAN_NAME_LIST_PLAN_NAME = "プラン変更申請にて変更可能なプラン一覧_定期_駐車場名_月額金額_駐車場備考_プラン_種別_支払パターン";
  28. protected const FIELDS = [
  29. ...parent::FIELDS,
  30. self::FIELD_PLAN_NAME => FieldType::SINGLE_LINE_TEXT,
  31. self::FIELD_SHOW_PLAN_NAME => FieldType::SINGLE_LINE_TEXT,
  32. self::FIELD_PARKING_NAME => FieldType::SINGLE_LINE_TEXT,
  33. self::FIELD_SEND_ITEM => FieldType::CHECK_BOX,
  34. self::FIELD_VEHICLE_TYPE => FieldType::SINGLE_LINE_TEXT,
  35. self::FIELD_TAX_AMOUNT => FieldType::NUMBER,
  36. self::FIELD_TAX_RATE => FieldType::NUMBER,
  37. self::FIELD_CAN_CHANGE_PLAN_NAME_LIST => FieldType::SUBTABLE,
  38. ];
  39. protected const SUB_TABLES = [
  40. self::FIELD_CAN_CHANGE_PLAN_NAME_LIST => CanChangePlanName::class,
  41. ];
  42. protected const FIELD_NAMES = [
  43. ...parent::FIELD_NAMES,
  44. ];
  45. protected function toArrayCustom(): array
  46. {
  47. return [
  48. 'has_season_ticket' => $this->hasSeasonTicket(),
  49. 'has_sticker' => $this->hasSticker(),
  50. 'can_apply_change_plan' => $this->canApplyChangePlan(),
  51. ];
  52. }
  53. public static function findByName(string $name): static
  54. {
  55. return static::getAccess()->first(static::getQuery()->where(static::FIELD_PLAN_NAME, $name));
  56. }
  57. public function hasSeasonTicket(): bool
  58. {
  59. return in_array("定期券", $this->sendItem);
  60. }
  61. public function hasSticker(): bool
  62. {
  63. return in_array("シール", $this->sendItem);
  64. }
  65. public function canApplyChangePlan(): bool
  66. {
  67. return $this->canChangePlanNameList->isNotEmpty();
  68. }
  69. }