Tweaking has_many "save" method.

Signed-off-by: Taylor Otwell <taylorotwell@gmail.com>
This commit is contained in:
Taylor Otwell 2012-04-03 10:56:55 -05:00
parent d0a701e8f7
commit 517da41a72
1 changed files with 3 additions and 0 deletions

View File

@ -20,6 +20,9 @@ public function results()
*/ */
public function save($models) 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); if ( ! is_array($models)) $models = array($models);
$current = $this->table->lists($this->model->key()); $current = $this->table->lists($this->model->key());