When dealing with a model,
all() is a static method.
It creates a new query object, and runs get() on that object
get() is not static, but can be called statically because of a magic method
in the Model class.
You cannot modify the query when using all() .
Model::all() // will retrieve all models
You can select columns to retrieve from the database by passing them as parameters to all()
Model::all('id') // will retrieve all models, but include only the id column
Model::get() do exactly the same thing. The only difference
is that Model::all() will create a query builder instance and call get()
for you. It does this in a static method on the Deal object.
If you call
Model::get() , the magic method will create a query builder instance
and call get() on that instance.
Model::all() will only accept columns as parameters. It is flexible and will
accept either an array or a list of them.
Model::get() will also only accept columns as parameters. However, it is not
flexible, so you must provide them in an array.
This only works because of the magic method. Just like
where() is not
defined in the Model class.
Just remember that you’re dealing with a query builder instance.