about afterSave

Hello! I have model "transactions" and related models "operations". One transactions have many operations. Now I use afterSave hook to update user balance (add operations sum to cache), but afterSave hook run on "transaction model" save. I need afterSave run after all "operations" save.

How can I do that?



1.7k

Maybe to call that method you need after commit?

Doesn't putting your code after commit will do what you want? Doesn't transaction on failed save throw an exception anyway? Check this - https://docs.phalconphp.com/pl/latest/reference/model-transactions.html#isolated-transactions