We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 66d1109 commit 8a2ca69Copy full SHA for 8a2ca69
src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php
@@ -256,11 +256,11 @@ protected function buildDictionary(Collection $results)
256
*/
257
public function firstOrNew(array $attributes = [], array $values = [])
258
{
259
- if (is_null($instance = $this->where($attributes)->first())) {
260
- $instance = $this->related->newInstance(array_merge($attributes, $values));
+ if (! is_null($instance = $this->where($attributes)->first())) {
+ return $instance;
261
}
262
263
- return $instance;
+ return $this->related->newInstance(array_merge($attributes, $values));
264
265
266
/**
0 commit comments