Skip to content

Commit e557a34

Browse files
committed
Merge pull request #569 from fungku/master
Allow EmbedsOneOrMany::saveMany to accept a collection
2 parents ea5ec06 + cacdcc1 commit e557a34

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/Jenssegers/Mongodb/Model.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function getQualifiedKeyName()
7575
* @param string $localKey
7676
* @param string $foreignKey
7777
* @param string $relation
78-
* @return EmbedsMany
78+
* @return \Jenssegers\Mongodb\Relations\EmbedsMany
7979
*/
8080
protected function embedsMany($related, $localKey = null, $foreignKey = null, $relation = null)
8181
{

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)