|  | @@ -7,16 +7,25 @@ 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)
 | 
											
												
													
														|  |  	{
 |  |  	{
 | 
											
												
													
														|  | -		$attributes = ($attributes instanceof Model) ? $attributes->attributes : $attributes;
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -		$attributes[$this->foreign_key()] = $this->base->get_key();
 |  | 
 | 
											
												
													
														|  | 
 |  | +		if ($attributes instanceof Model)
 | 
											
												
													
														|  | 
 |  | +		{
 | 
											
												
													
														|  | 
 |  | +			$attributes->set_attribute($this->foreign_key(), $this->base->get_key());
 | 
											
												
													
														|  | 
 |  | +			
 | 
											
												
													
														|  | 
 |  | +			return $attributes->save() ? $attributes : false;
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  | 
 |  | +		else
 | 
											
												
													
														|  | 
 |  | +		{
 | 
											
												
													
														|  | 
 |  | +			$attributes[$this->foreign_key()] = $this->base->get_key();
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -		return $this->model->create($attributes);
 |  | 
 | 
											
												
													
														|  | 
 |  | +			return $this->model->create($attributes);
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  |  	}
 |  |  	}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  	/**
 |  |  	/**
 |