File tree 2 files changed +7
-1
lines changed
src/Jenssegers/Mongodb/Relations
2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -217,7 +217,7 @@ protected function getEmbedded()
217
217
$ attributes = $ this ->parent ->getAttributes ();
218
218
219
219
// Get embedded models form parent attributes.
220
- $ embedded = isset ($ attributes [$ this ->localKey ]) ? (array ) $ attributes [$ this ->localKey ] : [] ;
220
+ $ embedded = isset ($ attributes [$ this ->localKey ]) ? (array ) $ attributes [$ this ->localKey ] : null ;
221
221
222
222
return $ embedded ;
223
223
}
Original file line number Diff line number Diff line change @@ -506,6 +506,12 @@ public function testEmbedsOneAssociate()
506
506
$ this ->assertEquals ('Mark Doe ' , $ user ->father ->name );
507
507
}
508
508
509
+ public function testEmbedsOneNullAssociation ()
510
+ {
511
+ $ user = User::create ();
512
+ $ this ->assertNull ($ user ->father );
513
+ }
514
+
509
515
public function testEmbedsOneDelete ()
510
516
{
511
517
$ user = User::create (['name ' => 'John Doe ' ]);
You can’t perform that action at this time.
0 commit comments