To obtain the average value of a column in Laravel, use the avg
method on the Eloquent query builder:
$average = DB::table('table_name')->avg('column_name');
Or, if using Eloquent:
$average = ModelName::avg('column_name');
This will return the average value of the specified column in the table.
Asked: 2023-07-07 14:56:34 +0000
Seen: 13 times
Last updated: Jul 07 '23