. */ declare(strict_types=1); namespace FireflyIII\Services\Internal\Destroy; use Exception; use FireflyIII\Events\DestroyedTransactionGroup; use FireflyIII\Models\TransactionGroup; /** * Class TransactionGroupDestroyService * * @codeCoverageIgnore */ class TransactionGroupDestroyService { /** * @param TransactionGroup $transactionGroup */ public function destroy(TransactionGroup $transactionGroup): void { /** @var JournalDestroyService $service */ $service = app(JournalDestroyService::class); foreach ($transactionGroup->transactionJournals as $journal) { $service->destroy($journal); } try { $transactionGroup->delete(); } catch (Exception $e) { // @phpstan-ignore-line // @ignoreException } // trigger just after destruction event(new DestroyedTransactionGroup($transactionGroup)); } }