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'; 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 ); }