{
foreach ($this->_relationships as $relationship) {
/** @var $relationship Field */
- if ($method == $relationship->getAttribute('name')) {
+ if ($method == $relationship->getAttribute('entity')) {
return $this->relationship($relationship);
}
}
case 'belongsTo':
return $this->belongsTo($field->getAttribute('model'), $field->getAttribute('name'));
case 'belongsToMany':
- return $this->belongsToMany($field->getAttribute('model'), $this->getRelationShipTable($field))->withPivot([$this->getForeignKey(), self::_toModel($field->getAttribute('model'))->getForeignKey()]);
+ return $this->belongsToMany($field->getAttribute('model'), $this->getRelationShipTable($field));
}
}