Model::selectRaw('count(*), min(some_field) as someMin, max(another_field) as someMax')->first();
// or in this case maybe better query builder instead of Eloquent:
DB::table('someTable')->selectRaw('count(*), min(some_field) as someMin, max(another_field) as someMax')->first();
Thanks. I knew about selectRaw but was wondering if there was some way a little more structured. It would be nice if the aggregate functions would return a Builder object so you could chain them together.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community