diff --git a/src/Utilities/Helper.php b/src/Utilities/Helper.php index 79e5c7b3..deda9521 100644 --- a/src/Utilities/Helper.php +++ b/src/Utilities/Helper.php @@ -156,10 +156,13 @@ public static function getOrMethod($method) public static function convertToArray($row) { $data = $row instanceof Arrayable ? $row->toArray() : (array) $row; - foreach (array_keys($data) as $key) { - if (is_object($data[$key]) || is_array($data[$key])) { - $data[$key] = self::convertToArray($data[$key]); + + foreach ($data as &$value) { + if (is_object($value) || is_array($value)) { + $value = self::convertToArray($value); } + + unset($value); } return $data;