From 0fe70dae17bcb4061d1e162a6541dbd1b3acc432 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 26 Aug 2016 07:37:09 +0200 Subject: [PATCH] Referring to Auth::user will not work from the command line. Signed-off-by: James Cole --- app/Rules/Actions/AddTag.php | 2 +- app/Rules/Actions/RemoveTag.php | 2 +- app/Rules/Actions/SetCategory.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Rules/Actions/AddTag.php b/app/Rules/Actions/AddTag.php index 1203ea1765..ef61c7dd77 100644 --- a/app/Rules/Actions/AddTag.php +++ b/app/Rules/Actions/AddTag.php @@ -46,7 +46,7 @@ class AddTag implements ActionInterface public function act(TransactionJournal $journal): bool { // journal has this tag maybe? - $tag = Tag::firstOrCreateEncrypted(['tag' => $this->action->action_value, 'user_id' => Auth::user()->id]); + $tag = Tag::firstOrCreateEncrypted(['tag' => $this->action->action_value, 'user_id' => $journal->user->id]); $count = $journal->tags()->where('tag_id', $tag->id)->count(); if ($count == 0) { diff --git a/app/Rules/Actions/RemoveTag.php b/app/Rules/Actions/RemoveTag.php index eaab0bb1e9..d3ebaf93bd 100644 --- a/app/Rules/Actions/RemoveTag.php +++ b/app/Rules/Actions/RemoveTag.php @@ -48,7 +48,7 @@ class RemoveTag implements ActionInterface // if tag does not exist, no need to continue: $name = $this->action->action_value; /** @var Tag $tag */ - $tag = Auth::user()->tags()->get()->filter( + $tag = $journal->user->tags()->get()->filter( function (Tag $tag) use ($name) { return $tag->tag == $name; } diff --git a/app/Rules/Actions/SetCategory.php b/app/Rules/Actions/SetCategory.php index 848dec089e..ef833e6278 100644 --- a/app/Rules/Actions/SetCategory.php +++ b/app/Rules/Actions/SetCategory.php @@ -46,7 +46,7 @@ class SetCategory implements ActionInterface public function act(TransactionJournal $journal): bool { $name = $this->action->action_value; - $category = Category::firstOrCreateEncrypted(['name' => $name, 'user_id' => Auth::user()->id]); + $category = Category::firstOrCreateEncrypted(['name' => $name, 'user_id' => $journal->user->id]); $journal->categories()->sync([$category->id]); return true;