action = $action; } /** * @param TransactionJournal $journal * * @return bool */ public function act(TransactionJournal $journal) { $name = $this->action->action_value; $category = Category::firstOrCreateEncrypted(['name' => $name, 'user_id' => Auth::user()->id]); Log::debug('Will set category "' . $name . '" (#' . $category->id . ') on journal #' . $journal->id . '.'); $journal->categories()->sync([$category->id]); return true; } }