From 13bac92a24dcda0ca31df100eac8e8dd7846220b Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 3 Mar 2016 08:38:24 +0100 Subject: [PATCH] Adapted attachment repository. --- app/Repositories/Account/AccountRepository.php | 2 +- .../Attachment/AttachmentRepository.php | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) 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(); } /**