categories()->first(); if (!is_null($category)) { $name = strtolower($category->name); // match on journal: if ($name === strtolower($this->triggerValue)) { Log::debug(sprintf('RuleTrigger CategoryIs for journal #%d: "%s" is "%s", return true.', $journal->id, $name, $this->triggerValue)); return true; } } if (is_null($category)) { // perhaps transactions have this category? /** @var Transaction $transaction */ foreach ($journal->transactions as $transaction) { $category = $transaction->categories()->first(); if (!is_null($category)) { $name = strtolower($category->name); if ($name === strtolower($this->triggerValue)) { Log::debug( sprintf( 'RuleTrigger CategoryIs for journal #%d (transaction #%d): "%s" is "%s", return true.', $journal->id, $transaction->id, $name, $this->triggerValue ) ); return true; } } } } Log::debug(sprintf('RuleTrigger CategoryIs for journal #%d: does not have category "%s", return false.', $journal->id, $this->triggerValue)); return false; } }