-
-
Notifications
You must be signed in to change notification settings - Fork 567
[5.x] Add firstOrfail
, firstOr
, sole
and exists
methods to base query builder
#9976
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
Conversation
…-base-query-builder # Conflicts: # tests/Data/Entries/EntryQueryBuilderTest.php
firstOrfail
, firstOr
, sole
and exists
methods to base query builderfirstOrfail
, firstOr
, sole
and exists
methods to base query builder
…-base-query-builder # Conflicts: # tests/Data/Entries/EntryQueryBuilderTest.php
I could use this on the UserQueryBuilder too :) |
This PR adds the method's to Statamic's base |
Oh, I tried to use it in a project with composer patches, and it said method not found. Might be my issue though. |
Are you using flat-file or Eloquent users? |
Flat file |
Hmm, this seems to work for me (I'm also using flat-file users): use Statamic\Facades\User;
User::query()->firstOrFail('ca291c8b-5629-4891-b506-bb2d7d9ad447'); |
Hi, do we know if this PR is planned to be accepted and merged soon? |
Sorry, we don't have an ETA for reviewing/merging this pull request. We'll get to it when we can. In the meantime, you can pull this PR into your project with a composer patch. |
No worries, thanks for your answer. |
…es. (ModelNotFoundException is a RecordsNotFoundException)
This pull request adds various useful methods to Statamic's base query builder:
firstOrFail
firstOr
sole
exists
true
if the query returns one or more results.On the back of #9815, I was thinking a few of Laravel's first/find methods could be added to our "base" query builder since they're useful for everything, not just entries & terms.