Skip to content

Firefly III: a personal finances manager

Adapted attachment repository.

James Cole13bac92a24dc
diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php
index be5f2b6c2d..a49ecad462 100644
--- a/app/Repositories/Account/AccountRepository.php
+++ b/app/Repositories/Account/AccountRepository.php
@@ -45,7 +45,7 @@ class AccountRepository implements AccountRepositoryInterface
*/
public function __construct(User $user)
{
- Log::debug('Constructed for user #' . $user->id . ' (' . $user->email . ')');
+ Log::debug('Constructed account repository for user #' . $user->id . ' (' . $user->email . ')');
$this->user = $user;
}
diff --git a/app/Repositories/Attachment/AttachmentRepository.php b/app/Repositories/Attachment/AttachmentRepository.php
index 5165d497f8..7cae0ed4ec 100644
--- a/app/Repositories/Attachment/AttachmentRepository.php
+++ b/app/Repositories/Attachment/AttachmentRepository.php
@@ -3,9 +3,10 @@ declare(strict_types = 1);
namespace FireflyIII\Repositories\Attachment;
-use Auth;
use FireflyIII\Models\Attachment;
+use FireflyIII\User;
use Illuminate\Support\Collection;
+use Log;
/**
* Class AttachmentRepository
@@ -14,6 +15,19 @@ use Illuminate\Support\Collection;
*/
class AttachmentRepository implements AttachmentRepositoryInterface
{
+ /** @var User */
+ private $user;
+
+ /**
+ * AttachmentRepository constructor.
+ *
+ * @param User $user
+ */
+ public function __construct(User $user)
+ {
+ Log::debug('Constructed attachment repository for user #' . $user->id . ' (' . $user->email . ')');
+ $this->user = $user;
+ }
/**
* @param Attachment $attachment
@@ -37,7 +51,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface
*/
public function get(): Collection
{
- return Auth::user()->attachments()->get();
+ return $this->user->attachments()->get();
}
/**