Commit 7438f7b1 authored by Jens Segers's avatar Jens Segers

Fixes #736

parent 30bb30cd
...@@ -7,6 +7,21 @@ use MongoDB\BSON\ObjectID; ...@@ -7,6 +7,21 @@ use MongoDB\BSON\ObjectID;
class EmbedsMany extends EmbedsOneOrMany class EmbedsMany extends EmbedsOneOrMany
{ {
/**
* Initialize the relation on a set of models.
*
* @param array $models
* @param string $relation
*/
public function initRelation(array $models, $relation)
{
foreach ($models as $model) {
$model->setRelation($relation, $this->related->newCollection());
}
return $models;
}
/** /**
* Get the results of the relationship. * Get the results of the relationship.
* *
......
...@@ -5,6 +5,21 @@ use MongoDB\BSON\ObjectID; ...@@ -5,6 +5,21 @@ use MongoDB\BSON\ObjectID;
class EmbedsOne extends EmbedsOneOrMany class EmbedsOne extends EmbedsOneOrMany
{ {
/**
* Initialize the relation on a set of models.
*
* @param array $models
* @param string $relation
*/
public function initRelation(array $models, $relation)
{
foreach ($models as $model) {
$model->setRelation($relation, null);
}
return $models;
}
/** /**
* Get the results of the relationship. * Get the results of the relationship.
* *
......
...@@ -75,23 +75,6 @@ abstract class EmbedsOneOrMany extends Relation ...@@ -75,23 +75,6 @@ abstract class EmbedsOneOrMany extends Relation
// There are no eager loading constraints. // There are no eager loading constraints.
} }
/**
* Initialize the relation on a set of models.
*
* @param array $models
* @param string $relation
*/
public function initRelation(array $models, $relation)
{
foreach ($models as $model) {
$model->setParentRelation($this);
$model->setRelation($relation, $this->related->newCollection());
}
return $models;
}
/** /**
* Match the eagerly loaded results to their parents. * Match the eagerly loaded results to their parents.
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment