File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed
src/Jenssegers/Mongodb/Relations Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -233,7 +233,7 @@ protected function getEmbedded()
233233 // Get raw attributes to skip relations and accessors.
234234 $attributes = $this->parent->getAttributes();
235235
236- $embedded = isset($attributes[$this->localKey]) ? (array) $attributes[$this->localKey] : [] ;
236+ $embedded = isset($attributes[$this->localKey]) ? (array) $attributes[$this->localKey] : null ;
237237
238238 return $embedded;
239239 }
Original file line number Diff line number Diff line change @@ -505,6 +505,12 @@ public function testEmbedsOneAssociate()
505505 $this->assertEquals('Mark Doe', $user->father->name);
506506 }
507507
508+ public function testEmbedsOneNullAssociation()
509+ {
510+ $user = User::create();
511+ $this->assertNull($user->father);
512+ }
513+
508514 public function testEmbedsOneDelete()
509515 {
510516 $user = User::create(['name' => 'John Doe']);
You can’t perform that action at this time.
0 commit comments