File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 1414use DirectoryTree \ImapEngine \Support \ForwardsCalls ;
1515use DirectoryTree \ImapEngine \Support \Str ;
1616use Illuminate \Support \Collection ;
17+ use Illuminate \Support \ItemNotFoundException ;
1718use Illuminate \Support \Traits \Conditionable ;
1819
1920/**
@@ -430,7 +431,19 @@ protected function populate(Collection $uids): MessageCollection
430431 */
431432 public function first (): ?MessageInterface
432433 {
433- return $ this ->limit (1 )->get ()->first ();
434+ try {
435+ return $ this ->firstOrFail ();
436+ } catch (ItemNotFoundException ) {
437+ return null ;
438+ }
439+ }
440+
441+ /**
442+ * Get the first message in the resulting collection or throw an exception.
443+ */
444+ public function firstOrFail (): MessageInterface
445+ {
446+ return $ this ->limit (1 )->get ()->firstOrFail ();
434447 }
435448
436449 /**
You can’t perform that action at this time.
0 commit comments