Skip to content

Commit eb2eb0a

Browse files
committed
fix: take $updateOnlyChanged into account when using casts
1 parent 94c7f08 commit eb2eb0a

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

system/BaseModel.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1841,8 +1841,11 @@ protected function transformDataToArray($row, string $type): array
18411841
}
18421842

18431843
// If it validates with entire rules, all fields are needed.
1844-
$onlyChanged = ($this->skipValidation === false && $this->cleanValidationRules === false)
1845-
? false : ($type === 'update');
1844+
if ($this->skipValidation === false && $this->cleanValidationRules === false) {
1845+
$onlyChanged = false;
1846+
} else {
1847+
$onlyChanged = ($type === 'update' && $this->updateOnlyChanged);
1848+
}
18461849

18471850
if ($this->useCasts()) {
18481851
if (is_array($row)) {
@@ -1862,13 +1865,6 @@ protected function transformDataToArray($row, string $type): array
18621865
// properties representing the collection elements, we need to grab
18631866
// them as an array.
18641867
elseif (is_object($row) && ! $row instanceof stdClass) {
1865-
// If it validates with entire rules, all fields are needed.
1866-
if ($this->skipValidation === false && $this->cleanValidationRules === false) {
1867-
$onlyChanged = false;
1868-
} else {
1869-
$onlyChanged = ($type === 'update' && $this->updateOnlyChanged);
1870-
}
1871-
18721868
$row = $this->objectToArray($row, $onlyChanged, true);
18731869
}
18741870

0 commit comments

Comments
 (0)