From 99dc8a3ff61a28f45f13de64e48c7365631d9fe4 Mon Sep 17 00:00:00 2001 From: mathijs mossink Date: Sun, 5 Feb 2023 23:27:13 +0100 Subject: [PATCH 1/2] added missing toArray trait --- src/Models/EboekhoudenRelation.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Models/EboekhoudenRelation.php b/src/Models/EboekhoudenRelation.php index dff6534..d86633f 100644 --- a/src/Models/EboekhoudenRelation.php +++ b/src/Models/EboekhoudenRelation.php @@ -3,10 +3,14 @@ namespace IntVent\EBoekhouden\Models; use DateTime; +use IntVent\EBoekhouden\Contracts\Arrayable; use IntVent\EBoekhouden\Exceptions\EboekhoudenException; +use IntVent\EBoekhouden\Traits\ProtectedFieldsToArrayTrait; -class EboekhoudenRelation +class EboekhoudenRelation implements Arrayable { + use ProtectedFieldsToArrayTrait; + protected ?int $id = null; protected string $relation_type = 'B'; protected string $la = '0'; From 6a64e76974680c7971b1345ebe77337527b215da Mon Sep 17 00:00:00 2001 From: falcomnl Date: Sat, 6 May 2023 13:27:30 +0200 Subject: [PATCH 2/2] make toArray() more flexible --- src/Traits/ProtectedFieldsToArrayTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Traits/ProtectedFieldsToArrayTrait.php b/src/Traits/ProtectedFieldsToArrayTrait.php index 7ccaeae..75f1aac 100644 --- a/src/Traits/ProtectedFieldsToArrayTrait.php +++ b/src/Traits/ProtectedFieldsToArrayTrait.php @@ -10,7 +10,7 @@ public function toArray() foreach ($return as $key => $value) { if (is_array($value)) { $return[$key] = array_map( - fn ($item): array => $item->toArray(), + fn ($item) => method_exists($item, 'toArray') ? $item->toArray() : $item, $value ); }