xxxxxxxxxx
The model's all method will retrieve all of the records from the model's associated database table
use App\Models\Flight;
foreach (Flight::all() as $flight) {
echo $flight->name;
}
The Eloquent all method will return all of the results in the model's table. However, since each Eloquent model serves as a query builder, you may add additional constraints to queries and then invoke the get method to retrieve the results
$flights = Flight::where('active', 1)
->orderBy('name')
->take(10)
->get();
xxxxxxxxxx
all() is a static method on the Eloquent\Model.
All it does is create a new query object and call get() on it.
With all(), you cannot modify the query performed at all
(except you can choose the columns to select by passing them as parameters).
get() is a method on the Eloquent\Builder object.