app/Statistics/Repository/PlaceRepository.php
public function statsPlaces(string $what = 'ALL', string $fact = '', int $parent = 0, bool $country = false): array
    {
        if ($fact) {
            return $this->queryFactPlaces($fact, $what, $country);
        }

        $query = DB::table('places')
            ->join('placelinks', static function (JoinClause $join): void {
                $join->on('pl_file', '=', 'p_file')
                    ->on('pl_p_id', '=', 'p_id');
            })
            ->where('p_file', '=', $this->tree->id());

        if ($parent > 0) {
            // Used by placehierarchy map modules
            $query->select(['p_place AS place'])
                ->selectRaw('COUNT(*) AS tot')
                ->where('p_id', '=', $parent)
                ->groupBy(['place']);
        } else {
            $query->select(['p_place AS country'])
                ->selectRaw('COUNT(*) AS tot')
                ->where('p_parent_id', '=', 0)
                ->groupBy(['country'])
                ->orderByDesc('tot')
                ->orderBy('country');
        }

        if ($what === 'INDI') {
            $query->join('individuals', static function (JoinClause $join): void {
                $join->on('pl_file', '=', 'i_file')
                    ->on('pl_gid', '=', 'i_id');
            });
        } elseif ($what === 'FAM') {
            $query->join('families', static function (JoinClause $join): void {
                $join->on('pl_file', '=', 'f_file')
                    ->on('pl_gid', '=', 'f_id');
            });
        }

        return $query->get()->all();
    }
public function statsPlaces(string $what = 'ALL', string $fact = '', int $parent = 0, bool $country = false): array
    {
        if ($fact) {
            return $this->queryFactPlaces($fact, $what, $country);
        }

        $query = DB::table('places')
            ->join('placelinks', static function (JoinClause $join): void {
                $join->on('pl_file', '=', 'p_file')
                    ->on('pl_p_id', '=', 'p_id');
            })
            ->where('p_file', '=', $this->tree->id());

        if ($parent > 0) {
            // Used by placehierarchy map modules
            $query->select(['p_place AS place'])
                ->selectRaw('COUNT(*) AS tot')
                ->where('p_id', '=', $parent)
                ->groupBy(['place']);
        } else {
            $query->select(['p_place AS country'])
                ->selectRaw('COUNT(*) AS tot')
                ->where('p_parent_id', '=', 0)
                ->groupBy(['country'])
                ->orderByDesc('tot')
                ->orderBy('country');
        }

        if ($what === 'INDI') {
            $query->join('individuals', static function (JoinClause $join): void {
                $join->on('pl_file', '=', 'i_file')
                    ->on('pl_gid', '=', 'i_id');
            });
        } elseif ($what === 'FAM') {
            $query->join('families', static function (JoinClause $join): void {
                $join->on('pl_file', '=', 'f_file')
                    ->on('pl_gid', '=', 'f_id');
            });
        }

        return $query->get()->all();
    }
public function statsPlaces ( string $ what = 'ALL' , string $ fact = '' , int $ parent = 0 , bool $ country = false ) : array { if ( $ fact ) { return $ this -> queryFactPlaces ( $ fact , $ what , $ country ) ; } $ query = DB :: table ( 'places' ) -> join ( 'placelinks' , static function ( JoinClause $ join ) : void { $ join -> on ( 'pl_file' , '=' , 'p_file' ) -> on ( 'pl_p_id' , '=' , 'p_id' ) ; } ) -> where ( 'p_file' , '=' , $ this -> tree -> id ( ) ) ; if ( $ parent > 0 ) { // Used by placehierarchy map modules $ query -> select ( [ 'p_place AS place' ] ) -> selectRaw ( 'COUNT(*) AS tot' ) -> where ( 'p_id' , '=' , $ parent ) -> groupBy ( [ 'place' ] ) ; } else { $ query -> select ( [ 'p_place AS country' ] ) -> selectRaw ( 'COUNT(*) AS tot' ) -> where ( 'p_parent_id' , '=' , 0 ) -> groupBy ( [ 'country' ] ) -> orderByDesc ( 'tot' ) -> orderBy ( 'country' ) ; } if ( $ what === 'INDI' ) { $ query -> join ( 'individuals' , static function ( JoinClause $ join ) : void { $ join -> on ( 'pl_file' , '=' , 'i_file' ) -> on ( 'pl_gid' , '=' , 'i_id' ) ; } ) ; } elseif ( $ what === 'FAM' ) { $ query -> join ( 'families' , static function ( JoinClause $ join ) : void { $ join -> on ( 'pl_file' , '=' , 'f_file' ) -> on ( 'pl_gid' , '=' , 'f_id' ) ; } ) ; } return $ query -> get ( ) -> all ( ) ; }
Query places.

@param string $what
@param string $fact
@param int    $parent
@param bool   $country

@return int[]|stdClass[]
Query places .