From 517da41a722f1a06891b9627706038ff100c89ef Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 3 Apr 2012 10:56:55 -0500 Subject: [PATCH] Tweaking has_many "save" method. Signed-off-by: Taylor Otwell --- laravel/database/eloquent/relationships/has_many.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/laravel/database/eloquent/relationships/has_many.php b/laravel/database/eloquent/relationships/has_many.php index df7f1451..ad152c07 100644 --- a/laravel/database/eloquent/relationships/has_many.php +++ b/laravel/database/eloquent/relationships/has_many.php @@ -20,6 +20,9 @@ public function results() */ public function save($models) { + // If the given "models" are not an array, we'll force them into an array so + // we can conveniently loop through them and insert all of them into the + // related database table assigned to the associated model instance. if ( ! is_array($models)) $models = array($models); $current = $this->table->lists($this->model->key());