Skip to content

Commit cacdcc1

Browse files
Allow EmbedsOneOrMany::saveMany to accept a collection
1 parent 316426d commit cacdcc1

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/Jenssegers/Mongodb/Relations/EmbedsOneOrMany.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,17 @@ public function save(Model $model)
156156
}
157157

158158
/**
159-
* Attach an array of models to the parent instance.
159+
* Attach a collection of models to the parent instance.
160160
*
161-
* @param array $models
162-
* @return array
161+
* @param \Illuminate\Database\Eloquent\Collection|array $models
162+
* @return \Illuminate\Database\Eloquent\Collection|array
163163
*/
164-
public function saveMany(array $models)
164+
public function saveMany($models)
165165
{
166-
array_walk($models, array($this, 'save'));
167-
166+
foreach ($models as $model) {
167+
$this->save($model);
168+
}
169+
168170
return $models;
169171
}
170172

0 commit comments

Comments
 (0)