@Khrome83, in the past there was already a request to include related entities within write operation, but atm i still think Gas ORM design already provide several hooks point, which make that request not emerged as a necessary requirement.
But this week, i’ve just completely put relationship insertion using this new method instead in my hooks/callback, within my company application, and i feel that really helpful 😊 Callbacks now can be used for other things which more custom/specific than that.
Would it make sense to have entities.user.parent and/or a option to find. Is .parent even needed in general, or does child work both ways depending on where your inserting from?
yes it does. Just to make it clear how this related->set works, lets throw all typical gas relationships :
// One-to-one
'wife' => ORM::has_one('\\Model\\Wife'), // Model\Wife is the child
'father' => ORM::belongs_to('\\Model\\Father'), // Model\Father is the child
// One-to-many
'kid' => ORM::has_many('\\Model\\Kid'), // Model\Kid is the child
// many-to-many
'job' => ORM::has_many('\\Model\\Job\\User => \\Model\\Job'), // Model\Job\User is the pivot and Model\Job is the childThen, regarding your schema :
Profiles
Belongs To - Users (or would Has One be Better)
Do you really need profiles being different entity from user entity? I think except you are in a very specific (rare) case, profile will be better as a part of user entity itself.
Articles
Belongs To - Users (or would Has One be Better)
...
Comments -
Belongs To - Articles
Belongs To - User (or would Has One be Better)
If you define one-to-many from user entity, than belongs-to already correct. belongs_to is different from has_one. Belongs to, implicitly tell that every record is bound to one parent record in foreign table. In has_one table, some record can have no child record.
So with finder, when I do All, would this cause any problems. For example if I want to get all Articles by a User as well as the comments and the comments users names...
...
I would not end up with something like this to get the comments user name. (not actual code)User()->Articles->Comments->User()->Name
I dont think there will be any issues about that. As long you define your entities relationship correctly, you should be fine 😊