diff --git a/src/Models/BaseModel.php b/src/Models/BaseModel.php index b728189..d4db28b 100644 --- a/src/Models/BaseModel.php +++ b/src/Models/BaseModel.php @@ -56,6 +56,12 @@ public function toArray() if (is_object($value) && $value instanceof Arrayable) { $object[$key] = $value->toArray(); } + + if (is_array($value)) { + $object[$key] = array_map(static function ($item) { + return is_object($item) && $item instanceof Arrayable ? $item->toArray() : $item; + }, $value); + } } return $object; @@ -166,4 +172,4 @@ function jsonSerialize() { return $this; } -} \ No newline at end of file +}