action = $action; } /** * @param TransactionJournal $journal * * @return bool */ public function act(TransactionJournal $journal): bool { /** @var BudgetRepositoryInterface $repository */ $repository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); $search = $this->action->action_value; $budgets = $repository->getActiveBudgets(); $budget = $budgets->filter( function (Budget $current) use ($search) { return $current->name == $search; } )->first(); if (!is_null($budget)) { Log::debug('Will set budget "' . $search . '" (#' . $budget->id . ') on journal #' . $journal->id . '.'); $journal->budgets()->sync([$budget->id]); } else { Log::debug('Could not find budget "' . $search . '". Failed.'); } return true; } }