-
Notifications
You must be signed in to change notification settings - Fork 1.5k
DOCSP-35982: Count usage example #2850
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
$biographies = Movie::where('genres', 'Biography') | ||
->count(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 2nd example for "a collection of object" would be:
$biographies = Movie::where('genres', 'Biography')->get();
$count = $biographies->count();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the where()
method return a collection of objects? If so, it seems (from my understanding) accurate to say that I'm calling count()
on a "collection of objects" if I chain count()
right after where()
. If not, I'll change the other code examples that mention a "collection of objects" as well to use get()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where()
returns a query builder. Calling ->get()
runs the find query and returns the collection of model instances.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM + 1 fix
docs/usage-examples/count.txt
Outdated
- ``where()``: matches documents in which the value of the ``genres`` field includes ``"Biography"``. | ||
- ``count()``: counts the number of matching documents. This method returns an integer value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- ``where()``: matches documents in which the value of the ``genres`` field includes ``"Biography"``. | |
- ``count()``: counts the number of matching documents. This method returns an integer value. | |
- ``where()``: Matches documents in which the value of the ``genres`` field includes ``"Biography"``. | |
- ``count()``: Counts the number of matching documents. This method returns an integer value. |
…l-mongodb into DOCSP-35982-count-usage
JIRA - https://jira.mongodb.org/browse/DOCSP-35982
Staging - https://preview-mongodbnorareidy.gatsbyjs.io/laravel/DOCSP-35982/usage-examples/count/
Checklist