diff --git a/laravel/database/eloquent/relationships/has_many.php b/laravel/database/eloquent/relationships/has_many.php index ad152c07..cbf216e7 100644 --- a/laravel/database/eloquent/relationships/has_many.php +++ b/laravel/database/eloquent/relationships/has_many.php @@ -31,10 +31,12 @@ public function save($models) { $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 // just use the existing instance instead of creating a fresh model // instance for the attributes. This allows for validation. - if ($attributes instanceof get_class($this->model)) + if ($attributes instanceof $class) { $model = $attributes; }