action = $action; } /** * @param TransactionJournal $journal * * @return bool */ public function act(TransactionJournal $journal): bool { /** @var BudgetRepositoryInterface $repository */ $repository = app(BudgetRepositoryInterface::class); $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)) { $journal->budgets()->sync([$budget->id]); } return true; } }