| Conditions | 2 |
| Paths | 1 |
| Total Lines | 26 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 1 | Features | 1 |
| 1 | <?php |
||
| 15 | public function boot() |
||
| 16 | { |
||
| 17 | Validator::extend('tags_exist', function ($attribute, $tagNames, $parameters) { |
||
| 18 | list($tagType) = $parameters; |
||
| 19 | $tagType = new TagType($tagType); |
||
| 20 | |||
| 21 | $exisitingTagNames = app(\App\Repositories\TagRepository::class) |
||
| 22 | ->getAllWithType($tagType) |
||
| 23 | ->lists('name') |
||
| 24 | ->toArray(); |
||
| 25 | |||
| 26 | if (!\Spatie\values_in_array($tagNames, $exisitingTagNames)) { |
||
| 27 | return false; |
||
| 28 | } |
||
| 29 | |||
| 30 | return true; |
||
| 31 | }); |
||
| 32 | |||
| 33 | Validator::extend('enum', function ($attribute, $value, $parameters) { |
||
| 34 | |||
| 35 | /** @var \App\Foundation\Models\Enums\Enum $class */ |
||
| 36 | $class = $parameters[0]; |
||
| 37 | |||
| 38 | return $class::isValid($value); |
||
| 39 | }); |
||
| 40 | } |
||
| 41 | } |
||
| 42 |