Allow passing in a model instance to relationship insert / update methods.

This commit is contained in:
Taylor Otwell
2012-03-20 09:03:31 -05:00
parent e540fd3b6d
commit 079400ff3d
3 changed files with 17 additions and 8 deletions

View File

@@ -15,11 +15,13 @@ class Belongs_To extends Relationship {
/**
* Update the parent model of the relationship.
*
* @param array $attributes
* @param Model|array $attributes
* @return int
*/
public function update($attributes)
{
$attributes = ($attributes instanceof Model) ? $attributes->get_dirty() : $attributes;
return $this->model->update($this->foreign_value(), $attributes);
}