Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.