File tree 3 files changed +30
-17
lines changed
src/Jenssegers/Mongodb/Relations
3 files changed +30
-17
lines changed Original file line number Diff line number Diff line change 7
7
8
8
class EmbedsMany extends EmbedsOneOrMany
9
9
{
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
+
10
25
/**
11
26
* Get the results of the relationship.
12
27
*
Original file line number Diff line number Diff line change 5
5
6
6
class EmbedsOne extends EmbedsOneOrMany
7
7
{
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
+
8
23
/**
9
24
* Get the results of the relationship.
10
25
*
Original file line number Diff line number Diff line change @@ -75,23 +75,6 @@ public function addEagerConstraints(array $models)
75
75
// There are no eager loading constraints.
76
76
}
77
77
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
-
95
78
/**
96
79
* Match the eagerly loaded results to their parents.
97
80
*
You can’t perform that action at this time.
0 commit comments