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 | 30 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 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 | $attributeValueForDataArray = null; |
||
| 22 | $requestAttributeValue = Arr::get($this->data, '_order_'.$attribute); |
||
| 23 | if ($entry && Str::contains($attribute, '.')) { |
||
| 24 | $attributeValueForDataArray = $requestAttributeValue; |
||
| 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 |