public function belongsTo($related, $foreignKey = '')
    {
        if (!$foreignKey && $related instanceof Model) {
            $column = $related->getTable();
        } else {
            $column = $foreignKey;
        }

        if (empty($related)) {
            unset($this->bean->$column);
        } elseif ($related instanceof Model) {
            $this->bean->$column = $related->getBean();
        } else {
            $this->bean->$column = $related;
        }
    }
public function belongsTo($related, $foreignKey = '')
    {
        if (!$foreignKey && $related instanceof Model) {
            $column = $related->getTable();
        } else {
            $column = $foreignKey;
        }

        if (empty($related)) {
            unset($this->bean->$column);
        } elseif ($related instanceof Model) {
            $this->bean->$column = $related->getBean();
        } else {
            $this->bean->$column = $related;
        }
    }
public function belongsTo ( $ related , $ foreignKey = '' ) { if ( ! $ foreignKey && $ related instanceof Model ) { $ column = $ related -> getTable ( ) ; } else { $ column = $ foreignKey ; } if ( empty ( $ related ) ) { unset ( $ this -> bean -> $ column ) ; } elseif ( $ related instanceof Model ) { $ this -> bean -> $ column = $ related -> getBean ( ) ; } else { $ this -> bean -> $ column = $ related ; } }
Create reverse one-to-many relationship
@param Model $related
@param type $foreignKey
Create reverse one - to - many relationship