Answer the question
In order to leave comments, you need to log in
How to abort saving a Laravel model instance?
The situation is the following. I deal with money transactions. If the server has not responded to the payment system's request, it repeats it.
Each transaction is recorded in the database.
Now I want to make sure that transactions are not re-recorded if the server gives an incorrect answer.
To do this, I take the Id that comes with the transaction and write it down in the corresponding field of the table.
Essence of the question. To check if a transaction with the same Id has already been created, I listen to the creating event. How can I interrupt the creation of a record from an event? Just delete the created object? I did not find such a method in the documentation, but, most likely, I just searched badly ...
Answer the question
In order to leave comments, you need to log in
At the database level, add a unique constraint to the Id field. Additionally, at the code level, before creating a transaction, check through the sql query exist.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question