app/GedcomRecord.php
public function linkingRecords(): array
    {
        $union = DB::table('change')
            ->where('gedcom_id', '=', $this->tree()->id())
            ->whereContains('new_gedcom', '@' . $this->xref() . '@')
            ->where('new_gedcom', 'NOT LIKE', '0 @' . $this->xref() . '@%')
            ->select(['xref']);

        $xrefs = DB::table('link')
            ->where('l_file', '=', $this->tree()->id())
            ->where('l_to', '=', $this->xref())
            ->select('l_from')
            ->union($union)
            ->pluck('l_from');

        return $xrefs->map(function (string $xref): GedcomRecord {
            return GedcomRecord::getInstance($xref, $this->tree);
        })->all();
    }
public function linkingRecords(): array
    {
        $union = DB::table('change')
            ->where('gedcom_id', '=', $this->tree()->id())
            ->whereContains('new_gedcom', '@' . $this->xref() . '@')
            ->where('new_gedcom', 'NOT LIKE', '0 @' . $this->xref() . '@%')
            ->select(['xref']);

        $xrefs = DB::table('link')
            ->where('l_file', '=', $this->tree()->id())
            ->where('l_to', '=', $this->xref())
            ->select('l_from')
            ->union($union)
            ->pluck('l_from');

        return $xrefs->map(function (string $xref): GedcomRecord {
            return GedcomRecord::getInstance($xref, $this->tree);
        })->all();
    }
public function linkingRecords ( ) : array { $ union = DB :: table ( 'change' ) -> where ( 'gedcom_id' , '=' , $ this -> tree ( ) -> id ( ) ) -> whereContains ( 'new_gedcom' , '@' . $ this -> xref ( ) . '@' ) -> where ( 'new_gedcom' , 'NOT LIKE' , '0 @' . $ this -> xref ( ) . '@%' ) -> select ( [ 'xref' ] ) ; $ xrefs = DB :: table ( 'link' ) -> where ( 'l_file' , '=' , $ this -> tree ( ) -> id ( ) ) -> where ( 'l_to' , '=' , $ this -> xref ( ) ) -> select ( 'l_from' ) -> union ( $ union ) -> pluck ( 'l_from' ) ; return $ xrefs -> map ( function ( string $ xref ) : GedcomRecord { return GedcomRecord :: getInstance ( $ xref , $ this -> tree ) ; } ) -> all ( ) ; }
Fetch XREFs of all records linked to a record - when deleting an object, we must
also delete all links to it.

@return GedcomRecord[]
Fetch XREFs of all records linked to a record - when deleting an object we must also delete all links to it .