Skip to content

Commit 8a2ca69

Browse files
committed
Invert the firstOrNew if statement
1 parent 66d1109 commit 8a2ca69

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,11 @@ protected function buildDictionary(Collection $results)
256256
*/
257257
public function firstOrNew(array $attributes = [], array $values = [])
258258
{
259-
if (is_null($instance = $this->where($attributes)->first())) {
260-
$instance = $this->related->newInstance(array_merge($attributes, $values));
259+
if (! is_null($instance = $this->where($attributes)->first())) {
260+
return $instance;
261261
}
262262

263-
return $instance;
263+
return $this->related->newInstance(array_merge($attributes, $values));
264264
}
265265

266266
/**

0 commit comments

Comments
 (0)