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()
214214 {
215215 return $ this ->foreignKey ;
216216 }
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- }
227217}
Original file line number Diff line number Diff line change @@ -287,6 +287,11 @@ public function testMorph()
287287
288288 $ photo = Photo::first ();
289289 $ 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 ());
290295 }
291296
292297 public function testEmbedsManySave ()
@@ -579,4 +584,20 @@ public function testEmbedsManyFindOrContains()
579584 $ this ->assertFalse ($ user ->addresses ()->contains ('123 ' ));
580585 }
581586
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+
582603}
Original file line number Diff line number Diff line change 77
88class User extends Eloquent implements UserInterface, RemindableInterface {
99
10- protected $ collection = 'users ' ;
1110 protected $ dates = array ('birthday ' );
1211 protected static $ unguarded = true ;
1312
You can’t perform that action at this time.
0 commit comments