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