Replies: 2 comments
-
I generally don't like firstOr methods and and the abort helper but that's just my personal preference. The firstOrFail I don't know what should throw, maybe create an ElementNotFound exception. The one liner for your specific use case is: $firstItem = $collection->first() ?? abort(403); |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
What do you think about adding
firstOr...
(firstOrFail
,firstOr
, etc.) methods to simple collections?So that we could:
Instead of:
Beta Was this translation helpful? Give feedback.
All reactions