How to implement relations() into yii2 model?

Into yii 1.0 i wrote this relation model:


	 * @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:

if($this->intervento->CODE != '06') 





I found nothing in the documentation.

How can I use the relations in Yii2?

You need this guide.

See section: "Working with Relational Data".

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


			$children = array();

			// loop through the relation looking for children

			foreach($allRelations as $key => $content){

				if(in_array('CHasManyRelation', $content)){




			return $children;

		}else {return null;}



Any ideas how to do that? Main problem is being able to get an array of all relations.