We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 7 |
| Paths | 24 |
| Total Lines | 32 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | public function validateRules(string $attribute, mixed $value): array |
||
| 10 | { |
||
| 11 | $entry = CrudPanelFacade::getCurrentEntry() !== false ? CrudPanelFacade::getCurrentEntry() : null; |
||
|
|
|||
| 12 | |||
| 13 | // `upload_multiple` sends [[0 => null]] when user doesn't upload anything |
||
| 14 | // assume that nothing changed on field so nothing is sent on the request. |
||
| 15 | if (count($value) === 1 && empty($value[0])) { |
||
| 16 | if ($entry) { |
||
| 17 | unset($this->data[$attribute]); |
||
| 18 | } else { |
||
| 19 | $this->data[$attribute] = []; |
||
| 20 | } |
||
| 21 | $value = []; |
||
| 22 | } |
||
| 23 | |||
| 24 | $previousValues = $entry?->{$attribute} ?? []; |
||
| 25 | if (is_string($previousValues)) { |
||
| 26 | $previousValues = json_decode($previousValues, true) ?? []; |
||
| 27 | } |
||
| 28 | |||
| 29 | $value = array_merge($previousValues, $value); |
||
| 30 | |||
| 31 | if ($entry) { |
||
| 32 | $filesDeleted = CrudPanelFacade::getRequest()->input('clear_'.$attribute) ?? []; |
||
| 33 | |||
| 34 | $data = $this->data; |
||
| 35 | $data[$attribute] = array_diff($value, $filesDeleted); |
||
| 36 | |||
| 37 | return $this->validateFieldAndFile($attribute, $value, $data); |
||
| 38 | } |
||
| 39 | |||
| 40 | return $this->validateFieldAndFile($attribute, $value); |
||
| 41 | } |
||
| 43 |