We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8840c56 commit 71697e5Copy full SHA for 71697e5
src/Models/AModel.php
@@ -133,7 +133,13 @@ public function __toArray($convert_dates = true): array
133
$value = $this->{'get' . ucfirst($var)}();
134
135
if (is_array($value)) {
136
- $result[$var] = array_map(fn(AModel $model) => $model->__toArray($convert_dates), $value);
+ $result[$var] = array_map(function($model) use ($convert_dates) {
137
+ if ($model instanceof AModel) {
138
+ return $model->__toArray($convert_dates);
139
+ } else {
140
+ return $model;
141
+ }
142
+ }, $value);
143
} elseif ($value instanceof AModel) {
144
$result[$var] = $value->__toArray($convert_dates);
145
} elseif ($value instanceof DateTime && $convert_dates) {
0 commit comments