Thank you Richard, however my problem is still unresolved. I wanted to provide additional details/clarity to the problem.
-
Users and presenters have a many-many relationship. Relationship between presentations and users is saved in a separate table (presentations_presenters_users), and is not available in the presentation or user tables. I have attached the screenshot of the presentations_presenters_users table below for reference.
-
Presentation record can updated with presenters (users) after creation as well. Users can be added/removed as presenters.
When I apply the solution listed above to the presentation model, I am unable to capture the following case of update - When a presenter is removed from the presentation.-
afterUpdate lifecycle method only has data pertaining to the updated record (ie information regarding the user/presenter that was removed is not available). As a result, I cannot update the count for the effected user.
-
beforeUpdate lifecycle method does not provide any details as to what update/modification will be made to the record. Hence, I am unable to update count (+/-).
-
Thank you for helping!
