action = $action; $this->journal = $journal; } /** * @return bool */ public function act() { $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 #' . $this->journal->id . '.'); $this->journal->categories()->sync([$category->id]); return true; } }