Referring to Auth::user will not work from the command line.

Signed-off-by: James Cole <thegrumpydictator@gmail.com>
This commit is contained in:
James Cole 2016-08-26 07:37:09 +02:00
parent 7079e76886
commit 0fe70dae17
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
3 changed files with 3 additions and 3 deletions

View File

@ -46,7 +46,7 @@ class AddTag implements ActionInterface
public function act(TransactionJournal $journal): bool public function act(TransactionJournal $journal): bool
{ {
// journal has this tag maybe? // 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(); $count = $journal->tags()->where('tag_id', $tag->id)->count();
if ($count == 0) { if ($count == 0) {

View File

@ -48,7 +48,7 @@ class RemoveTag implements ActionInterface
// if tag does not exist, no need to continue: // if tag does not exist, no need to continue:
$name = $this->action->action_value; $name = $this->action->action_value;
/** @var Tag $tag */ /** @var Tag $tag */
$tag = Auth::user()->tags()->get()->filter( $tag = $journal->user->tags()->get()->filter(
function (Tag $tag) use ($name) { function (Tag $tag) use ($name) {
return $tag->tag == $name; return $tag->tag == $name;
} }

View File

@ -46,7 +46,7 @@ class SetCategory implements ActionInterface
public function act(TransactionJournal $journal): bool public function act(TransactionJournal $journal): bool
{ {
$name = $this->action->action_value; $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]); $journal->categories()->sync([$category->id]);
return true; return true;