您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

77 行
2.5KB

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