Hello
Is there a way to see what the relationships were when we call the âbefore_relationship_addâ ?
Something like $bean->fetched_row, but for relationships, so we see a âsnapshotâ of the relationships when we first load the bean.
If I do $bean->load_relationship it will show me old and new related info all in one.
Solution:
Basically we can see what new record were added by checking
$arguments['related_module']
and
$arguments['related_id']
So for example if we have a 3 records with IDs 1,2 and 3 and the latest ID that was added is 3 ($arguments ârelated_idâ), that means that originally IDs 1 and 2 were there (these are the old relationships).
This is kind of backwards and was hoping that before_relationship_add would behave the same as before_relationship_delete (where as you can check what relationships were prior to deletion by simply calling load_relationship), but this is a working solution nonetheless
So technically speaking we can even do this in the after_relationship_add hook
1 Like