laravel get average code example
Example 1: laravel get average from a column
$avgStar = Model::avg('star');
Example 2: how do we calculate average in laravel 8
{
$average = collect([1, 5, 9, 5])->avg();
// Output : 5
$average = collect([10,20,30])->average();
// Output : 10
}