Skip to content

Commit

Permalink
Added values parameter to Builder::firstOrNew (#15567)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiandedeyne authored and taylorotwell committed Sep 27, 2016
1 parent c597c54 commit d3d0411
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Illuminate/Database/Eloquent/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,16 @@ public function findOrNew($id, $columns = ['*'])
* Get the first record matching the attributes or instantiate it.
*
* @param array $attributes
* @param array $values
* @return \Illuminate\Database\Eloquent\Model
*/
public function firstOrNew(array $attributes)
public function firstOrNew(array $attributes, array $values = [])
{
if (! is_null($instance = $this->where($attributes)->first())) {
return $instance;
}

return $this->model->newInstance($attributes);
return $this->model->newInstance($attributes + $values);
}

/**
Expand Down

0 comments on commit d3d0411

Please sign in to comment.