Tuesday, 6 July 2021

Laravel eloquent aggregate

 https://laravel.com/docs/5.7/eloquent#retrieving-aggregates


Retrieving Aggregates

You may also use the countsummax, and other aggregate methods provided by the query builder. These methods return the appropriate scalar value instead of a full model instance:

$count = App\Flight::where('active', 1)->count();

$max = App\Flight::where('active', 1)->max('price');

No comments:

Post a Comment