Fix issue updating categories.

This commit is contained in:
James Cole 2020-04-08 06:43:58 +02:00
parent 136af9625a
commit 4aec1f06e0
No known key found for this signature in database
GPG Key ID: B5669F9493CDE38D
2 changed files with 15 additions and 0 deletions

View File

@ -267,6 +267,7 @@ class CategoryRepository implements CategoryRepositoryInterface
{
/** @var CategoryUpdateService $service */
$service = app(CategoryUpdateService::class);
$service->setUser($this->user);
return $service->update($category, $data);
}

View File

@ -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;
}
}