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