src/ViewComposers/Dashboard/CountriesListComposer.php
private function calculateCountriesPercentage(Collection $countries)
    {
        $total = $countries->sum('count');

        return $countries->transform(function ($item) use ($total) {
            return $item + [
                'percentage' => round(($item['count'] / $total) * 100, 2)
            ];
        });
    }
private function calculateCountriesPercentage(Collection $countries)
    {
        $total = $countries->sum('count');

        return $countries->transform(function ($item) use ($total) {
            return $item + [
                'percentage' => round(($item['count'] / $total) * 100, 2)
            ];
        });
    }
private function calculateCountriesPercentage ( Collection $ countries ) { $ total = $ countries -> sum ( 'count' ) ; return $ countries -> transform ( function ( $ item ) use ( $ total ) { return $ item + [ 'percentage' => round ( ( $ item [ 'count' ] / $ total ) * 100 , 2 ) ] ; } ) ; }
Calculate countries percentage.

@param  \Illuminate\Support\Collection  $countries

@return \Illuminate\Support\Collection
Calculate countries percentage .