public function resolvePath()
    {
        $model = $this->getModel();
        $relations = explode('.', $this->getPath());
        $count = count($relations);

        if ($count === 1) {
            return $model;
        }

        foreach ($relations as $relation) {
            if ($count === 1) {
                return $model;
            }

            if ($model->exists && ($value = $model->getAttribute($relation)) instanceof Model) {
                $model = $value;

                $count--;
                continue;
            }

            if (method_exists($model, $relation)) {
                $relation = $model->{$relation}();

                if ($relation instanceof Relation) {
                    $model = $relation->getModel();
                    $count--;
                    continue;
                }
            }

            break;
        }

        throw new LogicException("Can not resolve path for field '{$this->getPath()}'. Probably relation definition is incorrect");
    }
public function resolvePath()
    {
        $model = $this->getModel();
        $relations = explode('.', $this->getPath());
        $count = count($relations);

        if ($count === 1) {
            return $model;
        }

        foreach ($relations as $relation) {
            if ($count === 1) {
                return $model;
            }

            if ($model->exists && ($value = $model->getAttribute($relation)) instanceof Model) {
                $model = $value;

                $count--;
                continue;
            }

            if (method_exists($model, $relation)) {
                $relation = $model->{$relation}();

                if ($relation instanceof Relation) {
                    $model = $relation->getModel();
                    $count--;
                    continue;
                }
            }

            break;
        }

        throw new LogicException("Can not resolve path for field '{$this->getPath()}'. Probably relation definition is incorrect");
    }
public function resolvePath ( ) { $ model = $ this -> getModel ( ) ; $ relations = explode ( '.' , $ this -> getPath ( ) ) ; $ count = count ( $ relations ) ; if ( $ count === 1 ) { return $ model ; } foreach ( $ relations as $ relation ) { if ( $ count === 1 ) { return $ model ; } if ( $ model -> exists && ( $ value = $ model -> getAttribute ( $ relation ) ) instanceof Model ) { $ model = $ value ; $ count -- ; continue ; } if ( method_exists ( $ model , $ relation ) ) { $ relation = $ model -> { $ relation } ( ) ; if ( $ relation instanceof Relation ) { $ model = $ relation -> getModel ( ) ; $ count -- ; continue ; } } break ; } throw new LogicException ( "Can not resolve path for field '{$this->getPath()}'. Probably relation definition is incorrect" ) ; }
Get model related to form element.

@return mixed
Get model related to form element .