Hi I am working on my project where some of their models are: Portfolios, Charities and Causes. Portfolio has a charities_id field which stores the charities_id corresponding to that portfolio which are related to the charities model and an empty causes field. On the other hand, inside the charities model there is the causes field, which contains the id of the causes (related to the Causes model). Below you can see the schemas:
What I would like to achieve is to create a pre save hook in Portfolio, so that when adding a new portfolio, it takes the charities_id that are added to that portfolio, look for them in the charities model and add in portfolio->causes the causes_id that are in charities->causes.
Is this possible?
I appreciate any help,