Answer the question
In order to leave comments, you need to log in
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question