. */ declare(strict_types=1); namespace FireflyIII\TransactionRules\Actions; use FireflyIII\Models\RuleAction; use FireflyIII\Models\TransactionJournal; use Log; /** * Class ClearCategory. */ class ClearCategory implements ActionInterface { /** @var RuleAction The rule action */ private $action; /** * TriggerInterface constructor. * * @param RuleAction $action */ public function __construct(RuleAction $action) { $this->action = $action; } /** * Clear all categories * * @param TransactionJournal $journal * * @return bool */ public function act(TransactionJournal $journal): bool { $journal->categories()->detach(); $journal->touch(); Log::debug(sprintf('RuleAction ClearCategory removed all categories from journal %d.', $journal->id)); return true; } }