protected function calcPercentages(array $total, array $names)
    {
        $percents = [];
        $all      = Arr::get($total, 'all');

        foreach ($total as $level => $count) {
            $percents[$level] = [
                'name'    => $names[$level],
                'count'   => $count,
                'percent' => $all ? round(($count / $all) * 100, 2) : 0,
            ];
        }

        return $percents;
    }
protected function calcPercentages(array $total, array $names)
    {
        $percents = [];
        $all      = Arr::get($total, 'all');

        foreach ($total as $level => $count) {
            $percents[$level] = [
                'name'    => $names[$level],
                'count'   => $count,
                'percent' => $all ? round(($count / $all) * 100, 2) : 0,
            ];
        }

        return $percents;
    }
protected function calcPercentages ( array $ total , array $ names ) { $ percents = [ ] ; $ all = Arr :: get ( $ total , 'all' ) ; foreach ( $ total as $ level => $ count ) { $ percents [ $ level ] = [ 'name' => $ names [ $ level ] , 'count' => $ count , 'percent' => $ all ? round ( ( $ count / $ all ) * 100 , 2 ) : 0 , ] ; } return $ percents ; }
Calculate the percentage.

@param  array  $total
@param  array  $names

@return array
Calculate the percentage .