User::query() return a Builder object. User::all() returns all the records from the user table.
Feb 10, 2018
5
Level 1
What's Model::query() function ?
Hi,
Could someone explain me the difference between User::query() and User::all() ?
I can't found any documentation about the query function.
Thank you
Level 42
Usually, you don't need to call query() on an Eloquent model. The methods you usually use, like all or where, call it or trigger query() under the hood and either return a model instance, an Eloquent collection, or a query builder instance.
1 like
Please or to participate in this conversation.