Fixing bug.

Signed-off-by: Taylor Otwell <taylorotwell@gmail.com>
This commit is contained in:
Taylor Otwell 2012-04-03 11:00:45 -05:00
parent 517da41a72
commit 6fdccd7496
1 changed files with 3 additions and 1 deletions

View File

@ -31,10 +31,12 @@ public function save($models)
{ {
$attributes[$this->foreign_key()] = $this->base->get_key(); $attributes[$this->foreign_key()] = $this->base->get_key();
$class = get_class($this->model);
// If the "attributes" are actually an array of the related model we'll // If the "attributes" are actually an array of the related model we'll
// just use the existing instance instead of creating a fresh model // just use the existing instance instead of creating a fresh model
// instance for the attributes. This allows for validation. // instance for the attributes. This allows for validation.
if ($attributes instanceof get_class($this->model)) if ($attributes instanceof $class)
{ {
$model = $attributes; $model = $attributes;
} }