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
This is Stefan. This is my first time submitting an issue for your package.
The problem
When using the update() method without retrieving the entity first, the Laravel events updating, updated, saving and saved are not fired. I noticed this when I was working on an Event for my application and I was wondering why the saved event was only fired when a new related entity is added, but it is not fired when an existing entity is edited.
Hi Alfa,
This is Stefan. This is my first time submitting an issue for your package.
The problem
When using the
update()
method without retrieving the entity first, the Laravel eventsupdating
,updated
,saving
andsaved
are not fired. I noticed this when I was working on anEvent
for my application and I was wondering why thesaved
event was only fired when a new related entity is added, but it is not fired when an existing entity is edited.laravel-hasmany-sync/src/ServiceProvider.php
Lines 75 to 76 in 16aac13
The reason why
saved
event is fired when a new related entity is added is becausecreateMany
method is used.laravel-hasmany-sync/src/ServiceProvider.php
Line 68 in 16aac13
Possible solution?
I would solve the issue by replacing the use of
update
method withLiterature
https://laravel.com/docs/8.x/eloquent#updates
https://stackoverflow.com/questions/41295032/laravel-eloquent-model-update-event-is-not-fired
What do you think?
Please let me know what do you think. If you are not OK with the change, would it be OK for me to make a fork?
Thank you very much for the package. It is really handy.
Best regards!
The text was updated successfully, but these errors were encountered: