public function addRelation(Relation $relation)
    {
        switch (get_class($relation)) {
            case BelongsTo::class:
                $this->relations['belongsTo'][] = $relation;
                break;

            case BelongsToMany::class:
                $this->relations['belongsToMany'][] = $relation;
                break;

            case HasOne::class:
                $this->relations['hasOne'][] = $relation;
                break;

            case HasMany::class:
                $this->relations['hasMany'][] = $relation;
                break;

            case HasManyThrough::class:
                $this->relations['hasManyThrough'][] = $relation;
                break;

            default:
                throw new \Exception("Unknown relation type " . get_class($relation));
        }
    }
public function addRelation(Relation $relation)
    {
        switch (get_class($relation)) {
            case BelongsTo::class:
                $this->relations['belongsTo'][] = $relation;
                break;

            case BelongsToMany::class:
                $this->relations['belongsToMany'][] = $relation;
                break;

            case HasOne::class:
                $this->relations['hasOne'][] = $relation;
                break;

            case HasMany::class:
                $this->relations['hasMany'][] = $relation;
                break;

            case HasManyThrough::class:
                $this->relations['hasManyThrough'][] = $relation;
                break;

            default:
                throw new \Exception("Unknown relation type " . get_class($relation));
        }
    }
public function addRelation ( Relation $ relation ) { switch ( get_class ( $ relation ) ) { case BelongsTo :: class : $ this -> relations [ 'belongsTo' ] [ ] = $ relation ; break ; case BelongsToMany :: class : $ this -> relations [ 'belongsToMany' ] [ ] = $ relation ; break ; case HasOne :: class : $ this -> relations [ 'hasOne' ] [ ] = $ relation ; break ; case HasMany :: class : $ this -> relations [ 'hasMany' ] [ ] = $ relation ; break ; case HasManyThrough :: class : $ this -> relations [ 'hasManyThrough' ] [ ] = $ relation ; break ; default : throw new \ Exception ( "Unknown relation type " . get_class ( $ relation ) ) ; } }
Add a relations

@param   Relation $relation The relation

@return  void
@throws  \Exception
Add a relations