You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @antonkomarev ! just a question. why would we need to registerAsLove{Reacter/Reactant} on Created event observer? It causes double saving event firing and DB operation.
Can we hook on Creating event and just pass reacter/reactant_id before model is created?
It seems to be working for me. Just wondering is there can be any issues with such approach?
The text was updated successfully, but these errors were encountered:
Good call! I don't remember right now why I made it on created event, but there definitely were a reasons. Will return back to this question in a free time.
If it will be done on creating event - we will be able to use non-nullable fields which you have asked for:
I found time to dive deeper to this question and tried to remember the reason why this this decision was made.
My motivation was simple: if creation of the Reactable/Reacterable model will fail, we will have empty Reactant/Reacter model not attached to anything.
Scenario:
Reacterable/Reactable model save called (creating observer method called)
Reacter/Reactant model created and its id set (but not persisted yet) to the Reacterable/Reactable model
Something bad happens (database connection issue, the electricity was cut off, etc)
But I think it may be solved by adding a console command, which will find all orphan Reactant/Reacter models and delete them.
Hi @antonkomarev ! just a question. why would we need to registerAsLove{Reacter/Reactant} on Created event observer? It causes double saving event firing and DB operation.
Can we hook on Creating event and just pass reacter/reactant_id before model is created?
It seems to be working for me. Just wondering is there can be any issues with such approach?
The text was updated successfully, but these errors were encountered: