protected function getAllChildsFromPath($models, $relationPath) {
        $path = explode('.', $relationPath, 2);
        $childs = [];
        $name = $path[0];
        foreach ($models as $model) {
            if (is_array($model->$name)) {
                $childs += $model->$name;
            } elseif ($model->$name) {
                $childs[] = $model->$name;
            }
        }
        if (!isset($path[1]) || !trim($path[1])) {
            return $childs;
        } else {
            return $this->getAllChildsFromPath($childs, $path[1]);
        }
    }
protected function getAllChildsFromPath($models, $relationPath) {
        $path = explode('.', $relationPath, 2);
        $childs = [];
        $name = $path[0];
        foreach ($models as $model) {
            if (is_array($model->$name)) {
                $childs += $model->$name;
            } elseif ($model->$name) {
                $childs[] = $model->$name;
            }
        }
        if (!isset($path[1]) || !trim($path[1])) {
            return $childs;
        } else {
            return $this->getAllChildsFromPath($childs, $path[1]);
        }
    }
protected function getAllChildsFromPath ( $ models , $ relationPath ) { $ path = explode ( '.' , $ relationPath , 2 ) ; $ childs = [ ] ; $ name = $ path [ 0 ] ; foreach ( $ models as $ model ) { if ( is_array ( $ model -> $ name ) ) { $ childs += $ model -> $ name ; } elseif ( $ model -> $ name ) { $ childs [ ] = $ model -> $ name ; } } if ( ! isset ( $ path [ 1 ] ) || ! trim ( $ path [ 1 ] ) ) { return $ childs ; } else { return $ this -> getAllChildsFromPath ( $ childs , $ path [ 1 ] ) ; } }
Get list of all model childs from a selected path.
@param DbModel[] $models
@param string $relationPath
@return DbModel[]
Get list of all model childs from a selected path .