NestedSetsBehavior.php
public function parents($depth = null) {
        $condition = [
            'and',
            [$this->leftAttribute => ['$lt' => $this->owner->getAttribute($this->leftAttribute)]],
            [$this->rightAttribute => ['$gt' => $this->owner->getAttribute($this->rightAttribute)]],
        ];

        if ($depth !== null) {
            $condition[] = [$this->depthAttribute => ['$gte' => $this->owner->getAttribute($this->depthAttribute) - $depth]];
        }

        $this->applyTreeAttributeCondition($condition);

        return $this->owner->find()->andWhere($condition)->addOrderBy([$this->leftAttribute => SORT_ASC]);
    }
public function parents($depth = null) {
        $condition = [
            'and',
            [$this->leftAttribute => ['$lt' => $this->owner->getAttribute($this->leftAttribute)]],
            [$this->rightAttribute => ['$gt' => $this->owner->getAttribute($this->rightAttribute)]],
        ];

        if ($depth !== null) {
            $condition[] = [$this->depthAttribute => ['$gte' => $this->owner->getAttribute($this->depthAttribute) - $depth]];
        }

        $this->applyTreeAttributeCondition($condition);

        return $this->owner->find()->andWhere($condition)->addOrderBy([$this->leftAttribute => SORT_ASC]);
    }
public function parents ( $ depth = null ) { $ condition = [ 'and' , [ $ this -> leftAttribute => [ '$lt' => $ this -> owner -> getAttribute ( $ this -> leftAttribute ) ] ] , [ $ this -> rightAttribute => [ '$gt' => $ this -> owner -> getAttribute ( $ this -> rightAttribute ) ] ] , ] ; if ( $ depth !== null ) { $ condition [ ] = [ $ this -> depthAttribute => [ '$gte' => $ this -> owner -> getAttribute ( $ this -> depthAttribute ) - $ depth ] ] ; } $ this -> applyTreeAttributeCondition ( $ condition ) ; return $ this -> owner -> find ( ) -> andWhere ( $ condition ) -> addOrderBy ( [ $ this -> leftAttribute => SORT_ASC ] ) ; }
Gets the parents of the node.
@param integer|null $depth the depth
@return \yii\db\ActiveQuery
Gets the parents of the node .