mercredi 24 janvier 2018

how to use Laravel model events and transactions together?

In general, how can we fire model events AFTER the transaction is committed? how to make sure the functions are not called immediately?

let's say I have a File model, and I want to add a 'deleted' event listener to remove the file from storage if the model is removed. now if we call the model's delete() function in the middle of a transaction, the file will be removed anyway, even if the transaction is being rolled back and our model is still there. how can we prevent this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire