Yeah, another MANY to MANY question.
I have the following tables
children
guardians_children
guardians
carriers
The logical ownership could also be illustrated like this.
children->guardians_children->guardians->carriers
Here are the relations;
children:
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'guardians_children' => array(self::HAS_MANY,'Guardians_Children','childrenId'),
);
}
guardians_children:
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'children' => array(self::BELONGS_TO,'Children','id'),
'guardians' => array(self::HAS_MANY,'Guardians','id'),
);
}
guardians:
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'guardians_children' => array(self::BELONGS_TO, 'Guardians_Children', 'id'),
'carriers' => array(self::HAS_ONE,'Carriers','id'),
);
}
From the ChildrenController, I am calling a method in the Children model that returns all the related information about the child. And it works just fine, as when I DUMP the object, I can see that it is all there. But I am not understanding the most efficient way to iterate over the object to say, get the guardian’s names, or the carrierId for example.