-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[9.x] add findOr method to Query/Builder #42290
Conversation
Another way of doing this is by using the the |
No support because you can do the same thing with plain PHP:
vs
(also the |
I'm 👎 here, for the reason provided by @bert-w. Since PHP 8.0, throw statements are also expressions. |
And yet none of you had problems with #42092, when the usage with throwing an exception was highlighted? |
good catch, didnt see that PR since I only browse here occasionally. However that being said I'd take the same stance. Any of the Anyway that means that this function is already merged so RIP |
True. Would say more, but this isn't the community for being able to take constructive criticism. |
Apparently there's also #42253 , no clue why these all pop up around the same time. It is kinda weird especially since Laravel 9.x now requires PHP 8+ which adds nice functionality to the language itself. I think it will take a couple of years (yes) for people to start using features frequently like the null safe ( |
This PR adds a findOr() method to the Query Builder. It is similar with #42092
Example usage:
Edit: I updated the example as it was wrong.
Probably there are other usage cases.