public function hasMany($link, $defaults = [])
    {
        if (!is_array($defaults)) {
            $defaults = ['model' => $defaults ?: 'Model_'.$link];
        }

        $defaults = array_merge([
            'our_field'   => $this->id_field,
            'their_field' => $this->owner->table.'_'.$this->id_field,
        ], $defaults);

        return $this->owner->hasMany($link, $defaults);
    }
public function hasMany($link, $defaults = [])
    {
        if (!is_array($defaults)) {
            $defaults = ['model' => $defaults ?: 'Model_'.$link];
        }

        $defaults = array_merge([
            'our_field'   => $this->id_field,
            'their_field' => $this->owner->table.'_'.$this->id_field,
        ], $defaults);

        return $this->owner->hasMany($link, $defaults);
    }
public function hasMany ( $ link , $ defaults = [ ] ) { if ( ! is_array ( $ defaults ) ) { $ defaults = [ 'model' => $ defaults ? : 'Model_' . $ link ] ; } $ defaults = array_merge ( [ 'our_field' => $ this -> id_field , 'their_field' => $ this -> owner -> table . '_' . $ this -> id_field , ] , $ defaults ) ; return $ this -> owner -> hasMany ( $ link , $ defaults ) ; }
Creates reference based on the field from the join.

@param string $link
@param array  $defaults

@return Reference_Many
Creates reference based on the field from the join .