Skip to content

Commit

Permalink
Fixes an issue in subscription endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
harm-smits committed Aug 27, 2021
1 parent 8840c56 commit 71697e5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Models/AModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,13 @@ public function __toArray($convert_dates = true): array
$value = $this->{'get' . ucfirst($var)}();

if (is_array($value)) {
$result[$var] = array_map(fn(AModel $model) => $model->__toArray($convert_dates), $value);
$result[$var] = array_map(function($model) use ($convert_dates) {
if ($model instanceof AModel) {
return $model->__toArray($convert_dates);
} else {
return $model;
}
}, $value);
} elseif ($value instanceof AModel) {
$result[$var] = $value->__toArray($convert_dates);
} elseif ($value instanceof DateTime && $convert_dates) {
Expand Down

0 comments on commit 71697e5

Please sign in to comment.