Skip to content

Commit 664e65d

Browse files
authored
Update firstOrFail logic (#38470)
1 parent 5ca0d16 commit 664e65d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Collection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ public function firstOrFail($key = null, $operator = null, $value = null)
11461146
? $this->operatorForWhere(...func_get_args())
11471147
: $key;
11481148

1149-
$items = $this->when($filter)->filter($filter);
1149+
$items = $this->unless($filter == null)->filter($filter);
11501150

11511151
if ($items->isEmpty()) {
11521152
throw new ItemNotFoundException;

LazyCollection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,7 @@ public function firstOrFail($key = null, $operator = null, $value = null)
10911091
: $key;
10921092

10931093
return $this
1094-
->when($filter)
1094+
->unless($filter == null)
10951095
->filter($filter)
10961096
->take(1)
10971097
->collect()

0 commit comments

Comments
 (0)