Commit d6e625e7 authored by Jens Segers's avatar Jens Segers

Add PR #741

parent 7438f7b1
......@@ -217,7 +217,7 @@ abstract class EmbedsOneOrMany extends Relation
$attributes = $this->parent->getAttributes();
// Get embedded models form parent attributes.
$embedded = isset($attributes[$this->localKey]) ? (array) $attributes[$this->localKey] : [];
$embedded = isset($attributes[$this->localKey]) ? (array) $attributes[$this->localKey] : null;
return $embedded;
}
......
......@@ -506,6 +506,12 @@ class EmbeddedRelationsTest extends TestCase
$this->assertEquals('Mark Doe', $user->father->name);
}
public function testEmbedsOneNullAssociation()
{
$user = User::create();
$this->assertNull($user->father);
}
public function testEmbedsOneDelete()
{
$user = User::create(['name' => 'John Doe']);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment