app/Services/CalendarService.php
public function getEventsList(int $jd1, int $jd2, string $events, bool $only_living, string $sort_by, Tree $tree): array
    {
        $found_facts = [];
        $facts       = [];

        foreach (range($jd1, $jd2) as $jd) {
            $found_facts = array_merge($found_facts, $this->getAnniversaryEvents($jd, $events, $tree));
        }

        foreach ($found_facts as $fact) {
            $record = $fact->record();
            // only living people ?
            if ($only_living) {
                if ($record instanceof Individual && $record->isDead()) {
                    continue;
                }
                if ($record instanceof Family) {
                    $husb = $record->husband();
                    if ($husb === null || $husb->isDead()) {
                        continue;
                    }
                    $wife = $record->wife();
                    if ($wife === null || $wife->isDead()) {
                        continue;
                    }
                }
            }
            $facts[] = $fact;
        }

        switch ($sort_by) {
            case 'anniv':
                $facts = Fact::sortFacts(Collection::make($facts))->all();
                break;

            case 'alpha':
                uasort($facts, static function (Fact $x, Fact $y): int {
                    return GedcomRecord::nameComparator()($x->record(), $y->record());
                });
                break;
        }

        return $facts;
    }
public function getEventsList(int $jd1, int $jd2, string $events, bool $only_living, string $sort_by, Tree $tree): array
    {
        $found_facts = [];
        $facts       = [];

        foreach (range($jd1, $jd2) as $jd) {
            $found_facts = array_merge($found_facts, $this->getAnniversaryEvents($jd, $events, $tree));
        }

        foreach ($found_facts as $fact) {
            $record = $fact->record();
            // only living people ?
            if ($only_living) {
                if ($record instanceof Individual && $record->isDead()) {
                    continue;
                }
                if ($record instanceof Family) {
                    $husb = $record->husband();
                    if ($husb === null || $husb->isDead()) {
                        continue;
                    }
                    $wife = $record->wife();
                    if ($wife === null || $wife->isDead()) {
                        continue;
                    }
                }
            }
            $facts[] = $fact;
        }

        switch ($sort_by) {
            case 'anniv':
                $facts = Fact::sortFacts(Collection::make($facts))->all();
                break;

            case 'alpha':
                uasort($facts, static function (Fact $x, Fact $y): int {
                    return GedcomRecord::nameComparator()($x->record(), $y->record());
                });
                break;
        }

        return $facts;
    }
public function getEventsList ( int $ jd1 , int $ jd2 , string $ events , bool $ only_living , string $ sort_by , Tree $ tree ) : array { $ found_facts = [ ] ; $ facts = [ ] ; foreach ( range ( $ jd1 , $ jd2 ) as $ jd ) { $ found_facts = array_merge ( $ found_facts , $ this -> getAnniversaryEvents ( $ jd , $ events , $ tree ) ) ; } foreach ( $ found_facts as $ fact ) { $ record = $ fact -> record ( ) ; // only living people ? if ( $ only_living ) { if ( $ record instanceof Individual && $ record -> isDead ( ) ) { continue ; } if ( $ record instanceof Family ) { $ husb = $ record -> husband ( ) ; if ( $ husb === null || $ husb -> isDead ( ) ) { continue ; } $ wife = $ record -> wife ( ) ; if ( $ wife === null || $ wife -> isDead ( ) ) { continue ; } } } $ facts [ ] = $ fact ; } switch ( $ sort_by ) { case 'anniv' : $ facts = Fact :: sortFacts ( Collection :: make ( $ facts ) ) -> all ( ) ; break ; case 'alpha' : uasort ( $ facts , static function ( Fact $ x , Fact $ y ) : int { return GedcomRecord :: nameComparator ( ) ( $ x -> record ( ) , $ y -> record ( ) ) ; } ) ; break ; } return $ facts ; }
Get the list of current and upcoming events, sorted by anniversary date

@param int    $jd1
@param int    $jd2
@param string $events
@param bool   $only_living
@param string $sort_by
@param Tree   $tree

@return Fact[]
Get the list of current and upcoming events sorted by anniversary date