領収証発行サービス
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.

48 lines
950B

  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Support\Str;
  4. use App\Codes\Custom;
  5. class Contract extends AppModel
  6. {
  7. const COL_NAME_NAME = 'name';
  8. const COL_NAME_CUSTOM = 'custom';
  9. const COL_NAME_CONTRACT_CODE = 'contract_code';
  10. public function getModelName(): string
  11. {
  12. return "契約";
  13. }
  14. public function includeCustom(string $target): bool
  15. {
  16. return in_array($target, $this->custom(), true);
  17. }
  18. /**
  19. * @return Custom[]
  20. */
  21. public function custom(): array
  22. {
  23. $custom = data_get($this, self::COL_NAME_CUSTOM);
  24. if ($custom) {
  25. $strList = explode(',', $custom);
  26. $ret = [];
  27. foreach ($strList as $str) {
  28. $c = Custom::tryFrom($str);
  29. if ($c !== null) {
  30. $ret[] = $c;
  31. }
  32. }
  33. return $ret;
  34. } else {
  35. return [];
  36. }
  37. }
  38. }