File tree Expand file tree Collapse file tree 3 files changed +30
-17
lines changed
src/Jenssegers/Mongodb/Relations Expand file tree Collapse file tree 3 files changed +30
-17
lines changed Original file line number Diff line number Diff line change 77
88class EmbedsMany extends EmbedsOneOrMany
99{
10+ /**
11+ * Initialize the relation on a set of models.
12+ *
13+ * @param array $models
14+ * @param string $relation
15+ */
16+ public function initRelation (array $ models , $ relation )
17+ {
18+ foreach ($ models as $ model ) {
19+ $ model ->setRelation ($ relation , $ this ->related ->newCollection ());
20+ }
21+
22+ return $ models ;
23+ }
24+
1025 /**
1126 * Get the results of the relationship.
1227 *
Original file line number Diff line number Diff line change 55
66class EmbedsOne extends EmbedsOneOrMany
77{
8+ /**
9+ * Initialize the relation on a set of models.
10+ *
11+ * @param array $models
12+ * @param string $relation
13+ */
14+ public function initRelation (array $ models , $ relation )
15+ {
16+ foreach ($ models as $ model ) {
17+ $ model ->setRelation ($ relation , null );
18+ }
19+
20+ return $ models ;
21+ }
22+
823 /**
924 * Get the results of the relationship.
1025 *
Original file line number Diff line number Diff line change @@ -75,23 +75,6 @@ public function addEagerConstraints(array $models)
7575 // There are no eager loading constraints.
7676 }
7777
78- /**
79- * Initialize the relation on a set of models.
80- *
81- * @param array $models
82- * @param string $relation
83- */
84- public function initRelation (array $ models , $ relation )
85- {
86- foreach ($ models as $ model ) {
87- $ model ->setParentRelation ($ this );
88-
89- $ model ->setRelation ($ relation , $ this ->related ->newCollection ());
90- }
91-
92- return $ models ;
93- }
94-
9578 /**
9679 * Match the eagerly loaded results to their parents.
9780 *
You can’t perform that action at this time.
0 commit comments