From 4aec1f06e0219ea908119feb4b81c6ef0bccc494 Mon Sep 17 00:00:00 2001 From: James Cole Date: Wed, 8 Apr 2020 06:43:58 +0200 Subject: [PATCH] Fix issue updating categories. --- app/Repositories/Category/CategoryRepository.php | 1 + .../Internal/Update/CategoryUpdateService.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.php index d3c9e0ad22..ffd61461e4 100644 --- a/app/Repositories/Category/CategoryRepository.php +++ b/app/Repositories/Category/CategoryRepository.php @@ -267,6 +267,7 @@ class CategoryRepository implements CategoryRepositoryInterface { /** @var CategoryUpdateService $service */ $service = app(CategoryUpdateService::class); + $service->setUser($this->user); return $service->update($category, $data); } diff --git a/app/Services/Internal/Update/CategoryUpdateService.php b/app/Services/Internal/Update/CategoryUpdateService.php index f7eeaa2222..205ef72b00 100644 --- a/app/Services/Internal/Update/CategoryUpdateService.php +++ b/app/Services/Internal/Update/CategoryUpdateService.php @@ -35,6 +35,9 @@ use Log; */ class CategoryUpdateService { + private $user; + + /** * Constructor. */ @@ -43,6 +46,9 @@ class CategoryUpdateService if ('testing' === config('app.env')) { Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this))); } + if(auth()->check()) { + $this->user = auth()->user(); + } } /** @@ -106,4 +112,12 @@ class CategoryUpdateService } } + /** + * @param mixed $user + */ + public function setUser($user): void + { + $this->user = $user; + } + }