Skip to content

Commit

Permalink
fix: TypeError when Time is passed to Model
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Apr 9, 2024
1 parent f846ffd commit 1a191b5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions system/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,9 @@ public function insertBatch(?array $set = null, ?bool $escape = null, int $batch
$row = (array) $row;
}

// Convert any Time instances to appropriate $dateFormat
$row = $this->timeToString($row);

// Validate every row.
if (! $this->skipValidation && ! $this->validate($row)) {
// Restore $cleanValidationRules
Expand Down Expand Up @@ -1845,8 +1848,6 @@ protected function transformDataToArray($row, string $type): array
$row = $this->converter->toDataSource($row);
} elseif ($row instanceof Entity) {
$row = $this->converter->extract($row, $onlyChanged);
// Convert any Time instances to appropriate $dateFormat
$row = $this->timeToString($row);
} elseif (is_object($row)) {
$row = $this->converter->extract($row, $onlyChanged);
}
Expand All @@ -1870,7 +1871,8 @@ protected function transformDataToArray($row, string $type): array
throw DataException::forEmptyDataset($type);
}

return $row;
// Convert any Time instances to appropriate $dateFormat
return $this->timeToString($row);
}

/**
Expand Down

0 comments on commit 1a191b5

Please sign in to comment.