toopay thanks for implementing the relationship insert.
=)
Just to clarify, if I have a pivot table, I use -
$job->related->set('entities.user.pivot', array(
Otherwise I would use -
$job->related->set('entities.user.child', array(
The other question i had was, if I have a one-to-many relationship,
lets say I have a Roles table which defines permissions, and a Users table. It is a One-To-Many with Users belonging to Roles, and Roles having many Users. So Users table has a ‘roles_id’.
If I was inserting a new User, since I am not making a new role, I would first need to lookup the ID of the role, or have it record to insert with the user? In most cases I assume I would know the ID of the role from the form and such. This is just a curiosity, and could be helpful?
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?
$user = Model\Users::make(array(
'name' => 'bob',
'email' => '[email protected]',
));
$user->related->set('entities.roles.parent', array(
'roles_id' => function() {
$role = Model\User::limit(1)->find_by_name('admin', FALSE);
return $role->id;
},
));
$user->save();
Additionally, in the existing example of the documentation, if the ID isn’t known can I do this -
$job->related->set('entities.user.pivot', array(
'user_id' => function() {
$user = Model\User::limit(1)->find_by_name('Bob', FALSE);
return $user->id;
},
));
I can see how the second PARAM is useful by passing FALSE we get a single object.