Skip to content

Commit 931dd2b

Browse files
committed
override method toArray to collection model
1 parent 7a018f4 commit 931dd2b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/Classes/ModelCollectionBase.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,19 @@ public function __call($name, $arguments)
5757
return $this->{$attribute};
5858
}
5959
}
60+
61+
public function toArray()
62+
{
63+
$items = parent::toArray();
64+
$result = [];
65+
foreach ($items as $item) {
66+
if ($item instanceof ModelItemBase) {
67+
$result[] = $item->toArray();
68+
} else {
69+
$result[] = $item;
70+
}
71+
}
72+
73+
return array_merge($result, $this->attributeValues);
74+
}
6075
}

0 commit comments

Comments
 (0)