diff --git a/src/Entities/PaymentRequest.php b/src/Entities/PaymentRequest.php index ee34c9e..13a7219 100644 --- a/src/Entities/PaymentRequest.php +++ b/src/Entities/PaymentRequest.php @@ -43,7 +43,7 @@ class PaymentRequest extends AbstractEntity /** * @var Payment[] */ - public $payments; + public $payments = []; /** * @var string @@ -93,9 +93,9 @@ public function setAttributes(array $attributes) } } - if ($payments = $attributes['payments'] ?? null) { - $this->payments = []; + $this->payments = []; + if ($payments = $attributes['payments'] ?? null) { foreach ($payments as $paymentData) { $payment = new Payment($this->getTikkie()); diff --git a/src/Entities/User.php b/src/Entities/User.php index 4b59adc..b28fc00 100644 --- a/src/Entities/User.php +++ b/src/Entities/User.php @@ -54,9 +54,9 @@ public function setAttributes(array $attributes) { parent::setAttributes($attributes); - if ($bankAccounts = $attributes['bankAccounts'] ?? null) { - $this->bankAccounts = []; + $this->bankAccounts = []; + if ($bankAccounts = $attributes['bankAccounts'] ?? null) { foreach ($bankAccounts as $bankAccountData) { $bankAccount = new BankAccount($this->getTikkie());