Closed stevebauman closed 2 years ago
Hi, @stevebauman.
Thanks for a solid PR!
Unfortunately firstOr
isn't part of Laravel Collections API, it's only available in Eloquent.
Therefore, merging this would break the adherence to the Laravel Collection API.
If you want another challenge, the sole
and firstOrFail
methods need to be implemented.
Ok! No worries 😄 , I'll PR the firstOrFail
method 👍
Description
This PR introduces the
firstOr()
method, which simplifiesfirst()
calls so you no longer have to pass innull
as the first parameter.Examples
Before:
After:
With callback:
No hard feelings on closure. I love this library and I really appreciate your hard work on this ❤️
Maybe we could also introduce a
firstOrFail()
as well that would throw an error when an item isn't found? What are your thoughts/opinion on this? I can submit a PR if you give the go ahead 👍