V
V
Vladimir2020-01-28 18:45:56
Laravel
Vladimir, 2020-01-28 18:45:56

Do Observers in Laravel guarantee a transaction?

For example, I have a model Cards and CardTransactions
DB::transaction - Guarantees me to rollback a new transaction if an error occurs during the write-off. And I can wrap the following steps in the database in my controller (or rather in the service):
- Adding a new CardTransaction
- Decrease the balance of the card

Does the Observer transaction rollback?
For example, I will have a TransactionObserver created() which will write off the balance of the card when the CardTransaction creation event has occurred. But in the event of an error in the Observer method, I expect the saving of the new CardTransaction to be cancelled.

Thank you all in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JhaoDa, 2020-01-28
@FonVald

Does the Observer transaction rollback?
No, because there are no transactions. This could be easily verified.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question