|
- <?php
-
- namespace App\Models;
-
- use Illuminate\Support\Str;
- use App\Codes\Custom;
-
- class Contract extends AppModel
- {
-
- const COL_NAME_NAME = 'name';
- const COL_NAME_CUSTOM = 'custom';
- const COL_NAME_CONTRACT_CODE = 'contract_code';
-
- public function getModelName(): string
- {
- return "契約";
- }
-
- public function includeCustom(string $target): bool
- {
- return in_array($target, $this->custom(), true);
- }
-
- /**
- * @return Custom[]
- */
- public function custom(): array
- {
- $custom = data_get($this, self::COL_NAME_CUSTOM);
- if ($custom) {
-
-
- $strList = explode(',', $custom);
- $ret = [];
- foreach ($strList as $str) {
- $c = Custom::tryFrom($str);
- if ($c !== null) {
- $ret[] = $c;
- }
- }
- return $ret;
- } else {
- return [];
- }
- }
- }
|