Browse Source

Fix method signature and return values of insert() method.

Franz Liedke 12 years ago
parent
commit
e46f07d436
1 changed files with 4 additions and 2 deletions
  1. 4 2
      laravel/database/eloquent/relationships/has_one_or_many.php

+ 4 - 2
laravel/database/eloquent/relationships/has_one_or_many.php

@@ -7,8 +7,10 @@ class Has_One_Or_Many extends Relationship {
 	/**
 	/**
 	 * Insert a new record for the association.
 	 * Insert a new record for the association.
 	 *
 	 *
+	 * If save is successful, the model will be returned, otherwise false.
+	 *
 	 * @param  Model|array  $attributes
 	 * @param  Model|array  $attributes
-	 * @return bool
+	 * @return Model|false
 	 */
 	 */
 	public function insert($attributes)
 	public function insert($attributes)
 	{
 	{
@@ -16,7 +18,7 @@ class Has_One_Or_Many extends Relationship {
 		{
 		{
 			$attributes->set_attribute($this->foreign_key(), $this->base->get_key());
 			$attributes->set_attribute($this->foreign_key(), $this->base->get_key());
 			
 			
-			return $attributes->save();
+			return $attributes->save() ? $attributes : false;
 		}
 		}
 		else
 		else
 		{
 		{