File tree Expand file tree Collapse file tree 3 files changed +21
-11
lines changed
src/Jenssegers/Mongodb/Relations Expand file tree Collapse file tree 3 files changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -214,14 +214,4 @@ public function getForeignKey()
214
214
{
215
215
return $ this ->foreignKey ;
216
216
}
217
-
218
- /**
219
- * Get the fully qualified "other key" for the relation.
220
- *
221
- * @return string
222
- */
223
- public function getOtherKey ()
224
- {
225
- return $ this ->otherKey ;
226
- }
227
217
}
Original file line number Diff line number Diff line change @@ -287,6 +287,11 @@ public function testMorph()
287
287
288
288
$ photo = Photo::first ();
289
289
$ this ->assertEquals ($ photo ->imageable ->name , $ user ->name );
290
+
291
+ $ user = User::with ('photos ' )->find ($ user ->_id );
292
+ $ relations = $ user ->getRelations ();
293
+ $ this ->assertTrue (array_key_exists ('photos ' , $ relations ));
294
+ $ this ->assertEquals (1 , $ relations ['photos ' ]->count ());
290
295
}
291
296
292
297
public function testEmbedsManySave ()
@@ -579,4 +584,20 @@ public function testEmbedsManyFindOrContains()
579
584
$ this ->assertFalse ($ user ->addresses ()->contains ('123 ' ));
580
585
}
581
586
587
+ public function testEmbedsManyEagerLoading ()
588
+ {
589
+ $ user = User::create (array ('name ' => 'John Doe ' ));
590
+ $ address1 = $ user ->addresses ()->save (new Address (array ('city ' => 'New York ' )));
591
+ $ address2 = $ user ->addresses ()->save (new Address (array ('city ' => 'Paris ' )));
592
+
593
+ $ user = User::find ($ user ->id );
594
+ $ relations = $ user ->getRelations ();
595
+ $ this ->assertFalse (array_key_exists ('addresses ' , $ relations ));
596
+
597
+ $ user = User::with ('addresses ' )->find ($ user ->id );
598
+ $ relations = $ user ->getRelations ();
599
+ $ this ->assertTrue (array_key_exists ('addresses ' , $ relations ));
600
+ $ this ->assertEquals (2 , $ relations ['addresses ' ]->count ());
601
+ }
602
+
582
603
}
Original file line number Diff line number Diff line change 7
7
8
8
class User extends Eloquent implements UserInterface, RemindableInterface {
9
9
10
- protected $ collection = 'users ' ;
11
10
protected $ dates = array ('birthday ' );
12
11
protected static $ unguarded = true ;
13
12
You can’t perform that action at this time.
0 commit comments