public function relatedKey($key, $model = false)
    {
        if (!$model) {
            $model = $this->model;
        }

        if (($methodBreaker = strpos($key, '.')) !== false) {
            $method = substr($key, 0, $methodBreaker);
            if (method_exists($model, $method)) {
                if (method_exists($model->$method, $submethod = str_replace($method.'.', '', $key))) {
                    return $model->$method->$submethod();
                }

                if (isset($model->$method->$submethod)) {
                    return $model->$method->$submethod;
                }

                return $model->getRelationValue($method);
            }
        }

        return false;
    }
public function relatedKey($key, $model = false)
    {
        if (!$model) {
            $model = $this->model;
        }

        if (($methodBreaker = strpos($key, '.')) !== false) {
            $method = substr($key, 0, $methodBreaker);
            if (method_exists($model, $method)) {
                if (method_exists($model->$method, $submethod = str_replace($method.'.', '', $key))) {
                    return $model->$method->$submethod();
                }

                if (isset($model->$method->$submethod)) {
                    return $model->$method->$submethod;
                }

                return $model->getRelationValue($method);
            }
        }

        return false;
    }
public function relatedKey ( $ key , $ model = false ) { if ( ! $ model ) { $ model = $ this -> model ; } if ( ( $ methodBreaker = strpos ( $ key , '.' ) ) !== false ) { $ method = substr ( $ key , 0 , $ methodBreaker ) ; if ( method_exists ( $ model , $ method ) ) { if ( method_exists ( $ model -> $ method , $ submethod = str_replace ( $ method . '.' , '' , $ key ) ) ) { return $ model -> $ method -> $ submethod ( ) ; } if ( isset ( $ model -> $ method -> $ submethod ) ) { return $ model -> $ method -> $ submethod ; } return $ model -> getRelationValue ( $ method ) ; } } return false ; }
Resolves a relation based on the key provided,
either on the current model or a provided model instance.

@param string $key
@param mixed  $model

@return mixed
Resolves a relation based on the key provided either on the current model or a provided model instance .