/**
* @return array relational rules.
*/
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(
'intervento' => array(self::BELONGS_TO, 'Interventi', 'ID_INTERVENTO'),
);
}
and then, i use the relation into model in this mode:
I had the following method in Yii1 and wish to apply the same logic with Yii2.
/**
* Get the children of the specified model
* @return array $children
*/
public function getChildren(){
$allRelations = $this->relations();
// only proceed if there are relation to check else
// exit with a null
if(isset($allRelations)){
$children = array();
// loop through the relation looking for children
foreach($allRelations as $key => $content){
if(in_array('CHasManyRelation', $content)){
$children[]=$content[1];
}
}
return $children;
}else {return null;}
}
Any ideas how to do that? Main problem is being able to get an array of all relations.