We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Total Complexity | 7 |
Total Lines | 31 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
11 | class ValidUpload extends BackpackCustomRule |
||
12 | { |
||
13 | /** |
||
14 | * Run the validation rule and return the array of errors. |
||
15 | */ |
||
16 | public function validateRules(string $attribute, mixed $value): array |
||
17 | { |
||
18 | $entry = CrudPanelFacade::getCurrentEntry(); |
||
|
|||
19 | |||
20 | if (! Arr::has($this->data, $attribute)) { |
||
21 | $requestAttribute = Arr::get($this->data, '_order_'.$attribute); |
||
22 | |||
23 | if ($entry && Arr::get($entry->{Str::before($attribute, '.')}, Str::after($attribute, '.')) === $requestAttribute) { |
||
24 | return []; |
||
25 | } |
||
26 | // set the empty attribute in data |
||
27 | Arr::set($this->data, $attribute, null); |
||
28 | } |
||
29 | |||
30 | $fieldErrors = $this->validateFieldRules($attribute, $value); |
||
31 | |||
32 | if (! empty($value) && ! empty($this->getFileRules())) { |
||
33 | $fileErrors = $this->validateFileRules($attribute, $value); |
||
34 | } |
||
35 | |||
36 | return array_merge($fieldErrors, $fileErrors ?? []); |
||
37 | } |
||
38 | |||
39 | public static function field(string|array|ValidationRule|Rule $rules = []): self |
||
42 | } |
||
43 | } |
||
44 |