src/ViewComposers/Dashboard/CountriesListComposer.php
private function getCountriesCountFromSessions(Carbon $start, Carbon $end)
    {
        return $this->getVisitorsFilteredByDateRange($start, $end)
            ->transform(function (Visitor $visitor) {
                return $visitor->hasGeoip()
                    ? [
                        'code'  => $visitor->geoip->iso_code,
                        'geoip' => $visitor->geoip,
                    ]
                    : [
                        'code'  => 'undefined',
                        'geoip' => null,
                    ];
            })
            ->groupBy('code')
            ->transform(function (Collection $items, $key) {
                return ($key === 'undefined')
                    ? [
                        'code'  => null,
                        'name'  => trans('tracker::generals.undefined'),
                        'count' => $items->count(),
                    ]
                    : [
                        'code'  => $key,
                        'name'  => $items->first()['geoip']->country,
                        'count' => $items->count(),
                    ];
            });
    }
private function getCountriesCountFromSessions(Carbon $start, Carbon $end)
    {
        return $this->getVisitorsFilteredByDateRange($start, $end)
            ->transform(function (Visitor $visitor) {
                return $visitor->hasGeoip()
                    ? [
                        'code'  => $visitor->geoip->iso_code,
                        'geoip' => $visitor->geoip,
                    ]
                    : [
                        'code'  => 'undefined',
                        'geoip' => null,
                    ];
            })
            ->groupBy('code')
            ->transform(function (Collection $items, $key) {
                return ($key === 'undefined')
                    ? [
                        'code'  => null,
                        'name'  => trans('tracker::generals.undefined'),
                        'count' => $items->count(),
                    ]
                    : [
                        'code'  => $key,
                        'name'  => $items->first()['geoip']->country,
                        'count' => $items->count(),
                    ];
            });
    }
private function getCountriesCountFromSessions ( Carbon $ start , Carbon $ end ) { return $ this -> getVisitorsFilteredByDateRange ( $ start , $ end ) -> transform ( function ( Visitor $ visitor ) { return $ visitor -> hasGeoip ( ) ? [ 'code' => $ visitor -> geoip -> iso_code , 'geoip' => $ visitor -> geoip , ] : [ 'code' => 'undefined' , 'geoip' => null , ] ; } ) -> groupBy ( 'code' ) -> transform ( function ( Collection $ items , $ key ) { return ( $ key === 'undefined' ) ? [ 'code' => null , 'name' => trans ( 'tracker::generals.undefined' ) , 'count' => $ items -> count ( ) , ] : [ 'code' => $ key , 'name' => $ items -> first ( ) [ 'geoip' ] -> country , 'count' => $ items -> count ( ) , ] ; } ) ; }
Get the countries count from sessions.

@param  \Carbon\Carbon  $start
@param  \Carbon\Carbon  $end

@return \Illuminate\Support\Collection
Get the countries count from sessions .