Merge pull request #1170 from kapv89/patch-4

Added a method to fluently set belongs-to relation
This commit is contained in:
Taylor Otwell 2013-01-05 13:51:39 -08:00
commit 13a1c5daac
1 changed files with 13 additions and 0 deletions

View File

@ -112,5 +112,18 @@ public function foreign_value()
{ {
return $this->base->get_attribute($this->foreign); return $this->base->get_attribute($this->foreign);
} }
/**
* Bind an object over a belongs-to relation using its id.
*
* @return Eloquent
*/
public function bind($id)
{
$this->base->fill(array($this->foreign => $id))->save();
return $this->base;
}
} }