I have two entities:
- Person
- Employee
Person hasOne Employee. Employee belongsTo Person.
Generally speaking, my task is: when person data changes, I need to make a copy of the model in revisions table. Each Person also hasMany PersonRevision. Kind of log of updating persons, which is used in many places in our application.
Technically, I separated Person and Employee, because not every person is employee and employee has a lot of additional columns.
So, the question is: when I update Person and do not touch its attributes but update the employee (which belongs to the person) attributes, the Update event does not fire in PersonObserver. And that's true since Person attributes has not been changed.
But
- I consider Employee as a part of Person, separated one to one in order to keep persons (which are not employees) table clean
- Every time person attributes or its employee attributes updated I need to create 2 revisions: person & employee. For this purpose I want to use Event Observers
So, how can I do this?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire