app/Module/RelationshipsChartModule.php
private function allAncestors($xref1, $xref2, $tree_id): array
    {
        $ancestors = [
            $xref1,
            $xref2,
        ];

        $queue = [
            $xref1,
            $xref2,
        ];
        while (!empty($queue)) {
            $parents = DB::table('link AS l1')
                ->join('link AS l2', static function (JoinClause $join): void {
                    $join
                        ->on('l1.l_to', '=', 'l2.l_to')
                        ->on('l1.l_file', '=', 'l2.l_file');
                })
                ->where('l1.l_file', '=', $tree_id)
                ->where('l1.l_type', '=', 'FAMC')
                ->where('l2.l_type', '=', 'FAMS')
                ->whereIn('l1.l_from', $queue)
                ->pluck('l2.l_from');

            $queue = [];
            foreach ($parents as $parent) {
                if (!in_array($parent, $ancestors, true)) {
                    $ancestors[] = $parent;
                    $queue[]     = $parent;
                }
            }
        }

        return $ancestors;
    }
private function allAncestors($xref1, $xref2, $tree_id): array
    {
        $ancestors = [
            $xref1,
            $xref2,
        ];

        $queue = [
            $xref1,
            $xref2,
        ];
        while (!empty($queue)) {
            $parents = DB::table('link AS l1')
                ->join('link AS l2', static function (JoinClause $join): void {
                    $join
                        ->on('l1.l_to', '=', 'l2.l_to')
                        ->on('l1.l_file', '=', 'l2.l_file');
                })
                ->where('l1.l_file', '=', $tree_id)
                ->where('l1.l_type', '=', 'FAMC')
                ->where('l2.l_type', '=', 'FAMS')
                ->whereIn('l1.l_from', $queue)
                ->pluck('l2.l_from');

            $queue = [];
            foreach ($parents as $parent) {
                if (!in_array($parent, $ancestors, true)) {
                    $ancestors[] = $parent;
                    $queue[]     = $parent;
                }
            }
        }

        return $ancestors;
    }
private function allAncestors ( $ xref1 , $ xref2 , $ tree_id ) : array { $ ancestors = [ $ xref1 , $ xref2 , ] ; $ queue = [ $ xref1 , $ xref2 , ] ; while ( ! empty ( $ queue ) ) { $ parents = DB :: table ( 'link AS l1' ) -> join ( 'link AS l2' , static function ( JoinClause $ join ) : void { $ join -> on ( 'l1.l_to' , '=' , 'l2.l_to' ) -> on ( 'l1.l_file' , '=' , 'l2.l_file' ) ; } ) -> where ( 'l1.l_file' , '=' , $ tree_id ) -> where ( 'l1.l_type' , '=' , 'FAMC' ) -> where ( 'l2.l_type' , '=' , 'FAMS' ) -> whereIn ( 'l1.l_from' , $ queue ) -> pluck ( 'l2.l_from' ) ; $ queue = [ ] ; foreach ( $ parents as $ parent ) { if ( ! in_array ( $ parent , $ ancestors , true ) ) { $ ancestors [ ] = $ parent ; $ queue [ ] = $ parent ; } } } return $ ancestors ; }
Find all ancestors of a list of individuals

@param string $xref1
@param string $xref2
@param int    $tree_id

@return string[]
Find all ancestors of a list of individuals