src/Titon/Model/Model.php
public function loadRelations() {
        foreach ([
            Relation::MANY_TO_ONE => $this->belongsTo,
            Relation::MANY_TO_MANY => $this->belongsToMany,
            Relation::ONE_TO_ONE => $this->hasOne,
            Relation::ONE_TO_MANY => $this->hasMany
        ] as $type => $relations) {
            foreach ($relations as $alias => $relation) {
                if (is_string($relation)) {
                    $relation = ['model' => $relation];
                }

                $relation = $relation + [
                    'model' => null,
                    'foreignKey' => null,
                    'relatedForeignKey' => null,
                    'conditions' => null,
                    'junction' => null
                ];

                switch ($type) {
                    case Relation::MANY_TO_ONE:
                        $this->belongsTo($alias, $relation['model'], $relation['foreignKey'], $relation['conditions']);
                    break;
                    case Relation::MANY_TO_MANY:
                        $this->belongsToMany($alias, $relation['model'], $relation['junction'], $relation['foreignKey'], $relation['relatedForeignKey'], $relation['conditions']);
                    break;
                    case Relation::ONE_TO_ONE:
                        $this->hasOne($alias, $relation['model'], $relation['relatedForeignKey'], $relation['conditions']);
                    break;
                    case Relation::ONE_TO_MANY:
                        $this->hasMany($alias, $relation['model'], $relation['relatedForeignKey'], $relation['conditions']);
                    break;
                }
            }
        }

        return $this;
    }
public function loadRelations() {
        foreach ([
            Relation::MANY_TO_ONE => $this->belongsTo,
            Relation::MANY_TO_MANY => $this->belongsToMany,
            Relation::ONE_TO_ONE => $this->hasOne,
            Relation::ONE_TO_MANY => $this->hasMany
        ] as $type => $relations) {
            foreach ($relations as $alias => $relation) {
                if (is_string($relation)) {
                    $relation = ['model' => $relation];
                }

                $relation = $relation + [
                    'model' => null,
                    'foreignKey' => null,
                    'relatedForeignKey' => null,
                    'conditions' => null,
                    'junction' => null
                ];

                switch ($type) {
                    case Relation::MANY_TO_ONE:
                        $this->belongsTo($alias, $relation['model'], $relation['foreignKey'], $relation['conditions']);
                    break;
                    case Relation::MANY_TO_MANY:
                        $this->belongsToMany($alias, $relation['model'], $relation['junction'], $relation['foreignKey'], $relation['relatedForeignKey'], $relation['conditions']);
                    break;
                    case Relation::ONE_TO_ONE:
                        $this->hasOne($alias, $relation['model'], $relation['relatedForeignKey'], $relation['conditions']);
                    break;
                    case Relation::ONE_TO_MANY:
                        $this->hasMany($alias, $relation['model'], $relation['relatedForeignKey'], $relation['conditions']);
                    break;
                }
            }
        }

        return $this;
    }
public function loadRelations ( ) { foreach ( [ Relation :: MANY_TO_ONE => $ this -> belongsTo , Relation :: MANY_TO_MANY => $ this -> belongsToMany , Relation :: ONE_TO_ONE => $ this -> hasOne , Relation :: ONE_TO_MANY => $ this -> hasMany ] as $ type => $ relations ) { foreach ( $ relations as $ alias => $ relation ) { if ( is_string ( $ relation ) ) { $ relation = [ 'model' => $ relation ] ; } $ relation = $ relation + [ 'model' => null , 'foreignKey' => null , 'relatedForeignKey' => null , 'conditions' => null , 'junction' => null ] ; switch ( $ type ) { case Relation :: MANY_TO_ONE : $ this -> belongsTo ( $ alias , $ relation [ 'model' ] , $ relation [ 'foreignKey' ] , $ relation [ 'conditions' ] ) ; break ; case Relation :: MANY_TO_MANY : $ this -> belongsToMany ( $ alias , $ relation [ 'model' ] , $ relation [ 'junction' ] , $ relation [ 'foreignKey' ] , $ relation [ 'relatedForeignKey' ] , $ relation [ 'conditions' ] ) ; break ; case Relation :: ONE_TO_ONE : $ this -> hasOne ( $ alias , $ relation [ 'model' ] , $ relation [ 'relatedForeignKey' ] , $ relation [ 'conditions' ] ) ; break ; case Relation :: ONE_TO_MANY : $ this -> hasMany ( $ alias , $ relation [ 'model' ] , $ relation [ 'relatedForeignKey' ] , $ relation [ 'conditions' ] ) ; break ; } } } return $ this ; }
Load relationships by reflecting current model properties.

@return \Titon\Model\Model
Load relationships by reflecting current model properties .