Skip to content

Commit

Permalink
Use force fill to populate the default attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
sileence committed Nov 12, 2016
1 parent d81d267 commit 99d7169
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Eloquent/Relations/HasOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected function getDefaultFor(Model $model)
if (is_callable($this->withDefault)) {
$result = call_user_func($this->withDefault);
} elseif (is_array($this->withDefault)) {
$result = $this->related->newInstance($this->withDefault);
$result = $this->related->newInstance()->forceFill($this->withDefault);
} elseif ($this->withDefault === true) {
$result = $this->related->newInstance();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Database/DatabaseEloquentHasOneTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function testHasOneWithArrayDefault()

$newModel = new EloquentHasOneModelStub($attributes);

$this->related->shouldReceive('newInstance')->once()->with($attributes)->andReturn($newModel);
$this->related->shouldReceive('newInstance')->once()->andReturn($newModel);

$this->assertSame($newModel, $relation->getResults());

Expand Down

0 comments on commit 99d7169

Please sign in to comment.