average function in laravel code example
Example: 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
}
{
$average = collect([1, 5, 9, 5])->avg();
// Output : 5
$average = collect([10,20,30])->average();
// Output : 10
}