app/Http/Controllers/BranchesController.php
private function loadIndividuals(Tree $tree, string $surname, bool $soundex_dm, bool $soundex_std): array
    {
        $individuals = DB::table('individuals')
            ->join('name', static function (JoinClause $join): void {
                $join
                    ->on('name.n_file', '=', 'individuals.i_file')
                    ->on('name.n_id', '=', 'individuals.i_id');
            })
            ->where('i_file', '=', $tree->id())
            ->where('n_type', '<>', '_MARNM')
            ->where(static function (Builder $query) use ($surname, $soundex_dm, $soundex_std): void {
                $query
                    ->where('n_surn', '=', $surname)
                    ->orWhere('n_surname', '=', $surname);

                if ($soundex_std) {
                    $sdx = Soundex::russell($surname);
                    if ($sdx !== '') {
                        foreach (explode(':', $sdx) as $value) {
                            $query->whereContains('n_soundex_surn_std', $value, 'or');
                        }
                    }
                }

                if ($soundex_dm) {
                    $sdx = Soundex::daitchMokotoff($surname);
                    if ($sdx !== '') {
                        foreach (explode(':', $sdx) as $value) {
                            $query->whereContains('n_soundex_surn_dm', $value, 'or');
                        }
                    }
                }
            })
            ->select(['individuals.*'])
            ->distinct()
            ->get()
            ->map(Individual::rowMapper())
            ->filter(GedcomRecord::accessFilter())
            ->all();

        usort($individuals, Individual::birthDateComparator());

        return $individuals;
    }
private function loadIndividuals(Tree $tree, string $surname, bool $soundex_dm, bool $soundex_std): array
    {
        $individuals = DB::table('individuals')
            ->join('name', static function (JoinClause $join): void {
                $join
                    ->on('name.n_file', '=', 'individuals.i_file')
                    ->on('name.n_id', '=', 'individuals.i_id');
            })
            ->where('i_file', '=', $tree->id())
            ->where('n_type', '<>', '_MARNM')
            ->where(static function (Builder $query) use ($surname, $soundex_dm, $soundex_std): void {
                $query
                    ->where('n_surn', '=', $surname)
                    ->orWhere('n_surname', '=', $surname);

                if ($soundex_std) {
                    $sdx = Soundex::russell($surname);
                    if ($sdx !== '') {
                        foreach (explode(':', $sdx) as $value) {
                            $query->whereContains('n_soundex_surn_std', $value, 'or');
                        }
                    }
                }

                if ($soundex_dm) {
                    $sdx = Soundex::daitchMokotoff($surname);
                    if ($sdx !== '') {
                        foreach (explode(':', $sdx) as $value) {
                            $query->whereContains('n_soundex_surn_dm', $value, 'or');
                        }
                    }
                }
            })
            ->select(['individuals.*'])
            ->distinct()
            ->get()
            ->map(Individual::rowMapper())
            ->filter(GedcomRecord::accessFilter())
            ->all();

        usort($individuals, Individual::birthDateComparator());

        return $individuals;
    }
private function loadIndividuals ( Tree $ tree , string $ surname , bool $ soundex_dm , bool $ soundex_std ) : array { $ individuals = DB :: table ( 'individuals' ) -> join ( 'name' , static function ( JoinClause $ join ) : void { $ join -> on ( 'name.n_file' , '=' , 'individuals.i_file' ) -> on ( 'name.n_id' , '=' , 'individuals.i_id' ) ; } ) -> where ( 'i_file' , '=' , $ tree -> id ( ) ) -> where ( 'n_type' , '<>' , '_MARNM' ) -> where ( static function ( Builder $ query ) use ( $ surname , $ soundex_dm , $ soundex_std ) : void { $ query -> where ( 'n_surn' , '=' , $ surname ) -> orWhere ( 'n_surname' , '=' , $ surname ) ; if ( $ soundex_std ) { $ sdx = Soundex :: russell ( $ surname ) ; if ( $ sdx !== '' ) { foreach ( explode ( ':' , $ sdx ) as $ value ) { $ query -> whereContains ( 'n_soundex_surn_std' , $ value , 'or' ) ; } } } if ( $ soundex_dm ) { $ sdx = Soundex :: daitchMokotoff ( $ surname ) ; if ( $ sdx !== '' ) { foreach ( explode ( ':' , $ sdx ) as $ value ) { $ query -> whereContains ( 'n_soundex_surn_dm' , $ value , 'or' ) ; } } } } ) -> select ( [ 'individuals.*' ] ) -> distinct ( ) -> get ( ) -> map ( Individual :: rowMapper ( ) ) -> filter ( GedcomRecord :: accessFilter ( ) ) -> all ( ) ; usort ( $ individuals , Individual :: birthDateComparator ( ) ) ; return $ individuals ; }
Fetch all individuals with a matching surname

@param Tree   $tree
@param string $surname
@param bool   $soundex_dm
@param bool   $soundex_std

@return Individual[]
Fetch all individuals with a matching surname