protected function addInverseRelations(&$result)
    {
        if ($this->inverseOf === null) {
            return;
        }

        foreach ($result as $i => $relatedModel) {
            if ($relatedModel instanceof ActiveRecordInterface) {
                if (!isset($inverseRelation)) {
                    $inverseRelation = $relatedModel->getRelation($this->inverseOf);
                }
                $relatedModel->populateRelation($this->inverseOf, $inverseRelation->multiple ? [$this->primaryModel] : $this->primaryModel);
            } else {
                if (!isset($inverseRelation)) {
                    /* @var $modelClass ActiveRecordInterface */
                    $modelClass = $this->modelClass;
                    $inverseRelation = $modelClass::instance()->getRelation($this->inverseOf);
                }
                $result[$i][$this->inverseOf] = $inverseRelation->multiple ? [$this->primaryModel] : $this->primaryModel;
            }
        }
    }
protected function addInverseRelations(&$result)
    {
        if ($this->inverseOf === null) {
            return;
        }

        foreach ($result as $i => $relatedModel) {
            if ($relatedModel instanceof ActiveRecordInterface) {
                if (!isset($inverseRelation)) {
                    $inverseRelation = $relatedModel->getRelation($this->inverseOf);
                }
                $relatedModel->populateRelation($this->inverseOf, $inverseRelation->multiple ? [$this->primaryModel] : $this->primaryModel);
            } else {
                if (!isset($inverseRelation)) {
                    /* @var $modelClass ActiveRecordInterface */
                    $modelClass = $this->modelClass;
                    $inverseRelation = $modelClass::instance()->getRelation($this->inverseOf);
                }
                $result[$i][$this->inverseOf] = $inverseRelation->multiple ? [$this->primaryModel] : $this->primaryModel;
            }
        }
    }
protected function addInverseRelations ( & $ result ) { if ( $ this -> inverseOf === null ) { return ; } foreach ( $ result as $ i => $ relatedModel ) { if ( $ relatedModel instanceof ActiveRecordInterface ) { if ( ! isset ( $ inverseRelation ) ) { $ inverseRelation = $ relatedModel -> getRelation ( $ this -> inverseOf ) ; } $ relatedModel -> populateRelation ( $ this -> inverseOf , $ inverseRelation -> multiple ? [ $ this -> primaryModel ] : $ this -> primaryModel ) ; } else { if ( ! isset ( $ inverseRelation ) ) { /* @var $modelClass ActiveRecordInterface */ $ modelClass = $ this -> modelClass ; $ inverseRelation = $ modelClass :: instance ( ) -> getRelation ( $ this -> inverseOf ) ; } $ result [ $ i ] [ $ this -> inverseOf ] = $ inverseRelation -> multiple ? [ $ this -> primaryModel ] : $ this -> primaryModel ; } } }
If applicable, populate the query's primary model into the related records' inverse relationship.
@param array $result the array of related records as generated by [[populate()]]
If applicable populate the query s primary model into the related records inverse relationship .