-
-
Notifications
You must be signed in to change notification settings - Fork 547
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
[5.x] Add firstOrfail
, firstOr
, sole
and exists
methods to base query builder
#9976
base: 5.x
Are you sure you want to change the base?
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'); |
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.