From 419975285c2633006ae68b9e42590d71bb931dc5 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 27 Dec 2024 13:02:23 +0100 Subject: [PATCH] Fix nullpointer --- app/Factory/PiggyBankFactory.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Factory/PiggyBankFactory.php b/app/Factory/PiggyBankFactory.php index 2cbc99e7c8..e4a09ca535 100644 --- a/app/Factory/PiggyBankFactory.php +++ b/app/Factory/PiggyBankFactory.php @@ -231,8 +231,8 @@ class PiggyBankFactory foreach ($accounts as $info) { if ($account->id === $info['account_id']) { if (array_key_exists($account->id, $accounts)) { - $toBeLinked[$account->id] = ['current_amount' => $account->pivot->current_amount ?? '0']; - Log::debug(sprintf('Prefilled for account #%d with amount %s', $account->id, $account->pivot->current_amount ?? '0')); + $toBeLinked[$account->id] = ['current_amount' => $account->pivot?->current_amount ?? '0']; + Log::debug(sprintf('Prefilled for account #%d with amount %s', $account->id, $account->pivot?->current_amount ?? '0')); } } } @@ -247,7 +247,7 @@ class PiggyBankFactory } if (array_key_exists('current_amount', $info)) { $toBeLinked[$account->id] = ['current_amount' => $info['current_amount']]; - Log::debug(sprintf('Will link account #%d with amount %s', $account->id, $account->pivot->current_amount)); + Log::debug(sprintf('Will link account #%d with amount %s', $account->id, $account->pivot?->current_amount ?? '0')); } if (!array_key_exists('current_amount', $info)) { $toBeLinked[$account->id] ??= [];