public function getWithRelation($name){
        $relations = $this->getRelations();
        if(isset($relations[$name])){
            $relation = $relations[$name];
            if($relation['relation'] === 'OTO'){
                return $this->getOneToOne($relation['target'], isset($relation['key'])?$relation['key']:null, isset($relation['target_key'])?$relation['target_key']:null);
            }
            elseif($relation['relation'] == 'OTM'){
                return $this->getOneToMany($relation['target'], isset($relation['key'])?$relation['key']:null, isset($relation['target_key'])?$relation['target_key']:null);
            }
            elseif($relation['relation'] == 'MTO'){
                return $this->getManyToOne($relation['target'], isset($relation['key'])?$relation['key']:null, isset($relation['target_key'])?$relation['target_key']:null);
            }
            elseif($relation['relation'] == 'MTM'){
                return $this->getManyToMany($relation['target'], $relation['through'], isset($relation['key'])?$relation['key']:null, isset($relation['target_key'])?$relation['target_key']:null);
            }
            else{
                throw new Exception('Invalid relation "'.$relation['relation'].'"');
            }
        }
        else{
            return false;
        }
    }
public function getWithRelation($name){
        $relations = $this->getRelations();
        if(isset($relations[$name])){
            $relation = $relations[$name];
            if($relation['relation'] === 'OTO'){
                return $this->getOneToOne($relation['target'], isset($relation['key'])?$relation['key']:null, isset($relation['target_key'])?$relation['target_key']:null);
            }
            elseif($relation['relation'] == 'OTM'){
                return $this->getOneToMany($relation['target'], isset($relation['key'])?$relation['key']:null, isset($relation['target_key'])?$relation['target_key']:null);
            }
            elseif($relation['relation'] == 'MTO'){
                return $this->getManyToOne($relation['target'], isset($relation['key'])?$relation['key']:null, isset($relation['target_key'])?$relation['target_key']:null);
            }
            elseif($relation['relation'] == 'MTM'){
                return $this->getManyToMany($relation['target'], $relation['through'], isset($relation['key'])?$relation['key']:null, isset($relation['target_key'])?$relation['target_key']:null);
            }
            else{
                throw new Exception('Invalid relation "'.$relation['relation'].'"');
            }
        }
        else{
            return false;
        }
    }
public function getWithRelation ( $ name ) { $ relations = $ this -> getRelations ( ) ; if ( isset ( $ relations [ $ name ] ) ) { $ relation = $ relations [ $ name ] ; if ( $ relation [ 'relation' ] === 'OTO' ) { return $ this -> getOneToOne ( $ relation [ 'target' ] , isset ( $ relation [ 'key' ] ) ? $ relation [ 'key' ] : null , isset ( $ relation [ 'target_key' ] ) ? $ relation [ 'target_key' ] : null ) ; } elseif ( $ relation [ 'relation' ] == 'OTM' ) { return $ this -> getOneToMany ( $ relation [ 'target' ] , isset ( $ relation [ 'key' ] ) ? $ relation [ 'key' ] : null , isset ( $ relation [ 'target_key' ] ) ? $ relation [ 'target_key' ] : null ) ; } elseif ( $ relation [ 'relation' ] == 'MTO' ) { return $ this -> getManyToOne ( $ relation [ 'target' ] , isset ( $ relation [ 'key' ] ) ? $ relation [ 'key' ] : null , isset ( $ relation [ 'target_key' ] ) ? $ relation [ 'target_key' ] : null ) ; } elseif ( $ relation [ 'relation' ] == 'MTM' ) { return $ this -> getManyToMany ( $ relation [ 'target' ] , $ relation [ 'through' ] , isset ( $ relation [ 'key' ] ) ? $ relation [ 'key' ] : null , isset ( $ relation [ 'target_key' ] ) ? $ relation [ 'target_key' ] : null ) ; } else { throw new Exception ( 'Invalid relation "' . $ relation [ 'relation' ] . '"' ) ; } } else { return false ; } }
Get a field with relation
@param  string $name
@return mixed
Get a field with relation