Skip to content

Firefly III: a personal finances manager

Fix https://github.com/firefly-iii/firefly-iii/issues/11792

Sander Dorigo9b05c777cd5c
diff --git a/app/Helpers/Attachments/AttachmentHelper.php b/app/Helpers/Attachments/AttachmentHelper.php
index a3f545ea89..e337aac8ef 100644
--- a/app/Helpers/Attachments/AttachmentHelper.php
+++ b/app/Helpers/Attachments/AttachmentHelper.php
@@ -230,7 +230,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$count = 0;
// ignore lines about polymorphic calls.
if ($model instanceof PiggyBank) {
- $count = $model->account->user->attachments()->where('md5', $md5)->where('attachable_id', $model->id)->where('attachable_type', $class)->count();
+ $count = $model->accounts()->first()->user->attachments()->where('md5', $md5)->where('attachable_id', $model->id)->where('attachable_type', $class)->count();
}
if (!$model instanceof PiggyBank) {
$count = $model->user->attachments()->where('md5', $md5)->where('attachable_id', $model->id)->where('attachable_type', $class)->count();
@@ -260,7 +260,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$user = $model->user;
// ignore lines about polymorphic calls.
if ($model instanceof PiggyBank) {
- $user = $model->account->user;
+ $user = $model->accounts()->first()->user;
}
$attachment = new Attachment(); // create Attachment object.