public function buildRelationXTypeInfo(Model $model, $key)
    {
        $relation = $model->$key();

        switch (true) {

            case $relation instanceof BelongsTo:
                return $this->buildBelongsToInfo($key, $relation);

            case $relation instanceof BelongsToMany:
                return $this->buildBelongsToManyInfo($key, $relation);

            case $relation instanceof HasMany:
                return $this->buildHasManyInfo($key, $relation);

            case $relation instanceof HasOne:
                return $this->buildHasOneInfo($key, $relation);

            case $relation instanceof HasManyThrough:
                return $this->buildHasManyThroughInfo($key, $relation);

            case $relation instanceof MorphOne:
                return $this->buildMorphOneInfo($key, $relation);

            case $relation instanceof MorphMany:
                return $this->buildMorphManyInfo($key, $relation);

            default:
                $modelClass = get_class($model);
                $relationType = Type::of($relation);

                throw new UnsupportedParameterException("Result of $modelClass->$key() did not return a Relation (it returned $relationType)");
        }
    }
public function buildRelationXTypeInfo(Model $model, $key)
    {
        $relation = $model->$key();

        switch (true) {

            case $relation instanceof BelongsTo:
                return $this->buildBelongsToInfo($key, $relation);

            case $relation instanceof BelongsToMany:
                return $this->buildBelongsToManyInfo($key, $relation);

            case $relation instanceof HasMany:
                return $this->buildHasManyInfo($key, $relation);

            case $relation instanceof HasOne:
                return $this->buildHasOneInfo($key, $relation);

            case $relation instanceof HasManyThrough:
                return $this->buildHasManyThroughInfo($key, $relation);

            case $relation instanceof MorphOne:
                return $this->buildMorphOneInfo($key, $relation);

            case $relation instanceof MorphMany:
                return $this->buildMorphManyInfo($key, $relation);

            default:
                $modelClass = get_class($model);
                $relationType = Type::of($relation);

                throw new UnsupportedParameterException("Result of $modelClass->$key() did not return a Relation (it returned $relationType)");
        }
    }
public function buildRelationXTypeInfo ( Model $ model , $ key ) { $ relation = $ model -> $ key ( ) ; switch ( true ) { case $ relation instanceof BelongsTo : return $ this -> buildBelongsToInfo ( $ key , $ relation ) ; case $ relation instanceof BelongsToMany : return $ this -> buildBelongsToManyInfo ( $ key , $ relation ) ; case $ relation instanceof HasMany : return $ this -> buildHasManyInfo ( $ key , $ relation ) ; case $ relation instanceof HasOne : return $ this -> buildHasOneInfo ( $ key , $ relation ) ; case $ relation instanceof HasManyThrough : return $ this -> buildHasManyThroughInfo ( $ key , $ relation ) ; case $ relation instanceof MorphOne : return $ this -> buildMorphOneInfo ( $ key , $ relation ) ; case $ relation instanceof MorphMany : return $ this -> buildMorphManyInfo ( $ key , $ relation ) ; default : $ modelClass = get_class ( $ model ) ; $ relationType = Type :: of ( $ relation ) ; throw new UnsupportedParameterException ( "Result of $modelClass->$key() did not return a Relation (it returned $relationType)" ) ; } }
Return an array describing the xtype of a relational property

@param Model $model
@param string $key

@return array
Return an array describing the xtype of a relational property