app/Http/Controllers/CalendarController.php
private function applyFilter(array $facts, string $filterof, string $filtersx): array
    {
        $filtered      = [];
        $hundred_years = Carbon::now()->subYears(100)->julianDay();
        foreach ($facts as $fact) {
            $record = $fact->record();
            if ($filtersx) {
                // Filter on sex
                if ($record instanceof Individual && $filtersx !== $record->sex()) {
                    continue;
                }
                // Can't display families if the sex filter is on.
                if ($record instanceof Family) {
                    continue;
                }
            }
            // Filter living individuals
            if ($filterof === 'living') {
                if ($record instanceof Individual && $record->isDead()) {
                    continue;
                }
                if ($record instanceof Family) {
                    $husb = $record->husband();
                    $wife = $record->wife();
                    if ($husb && $husb->isDead() || $wife && $wife->isDead()) {
                        continue;
                    }
                }
            }
            // Filter on recent events
            if ($filterof === 'recent' && $fact->date()->maximumJulianDay() < $hundred_years) {
                continue;
            }
            $filtered[] = $fact;
        }

        return $filtered;
    }
private function applyFilter(array $facts, string $filterof, string $filtersx): array
    {
        $filtered      = [];
        $hundred_years = Carbon::now()->subYears(100)->julianDay();
        foreach ($facts as $fact) {
            $record = $fact->record();
            if ($filtersx) {
                // Filter on sex
                if ($record instanceof Individual && $filtersx !== $record->sex()) {
                    continue;
                }
                // Can't display families if the sex filter is on.
                if ($record instanceof Family) {
                    continue;
                }
            }
            // Filter living individuals
            if ($filterof === 'living') {
                if ($record instanceof Individual && $record->isDead()) {
                    continue;
                }
                if ($record instanceof Family) {
                    $husb = $record->husband();
                    $wife = $record->wife();
                    if ($husb && $husb->isDead() || $wife && $wife->isDead()) {
                        continue;
                    }
                }
            }
            // Filter on recent events
            if ($filterof === 'recent' && $fact->date()->maximumJulianDay() < $hundred_years) {
                continue;
            }
            $filtered[] = $fact;
        }

        return $filtered;
    }
private function applyFilter ( array $ facts , string $ filterof , string $ filtersx ) : array { $ filtered = [ ] ; $ hundred_years = Carbon :: now ( ) -> subYears ( 100 ) -> julianDay ( ) ; foreach ( $ facts as $ fact ) { $ record = $ fact -> record ( ) ; if ( $ filtersx ) { // Filter on sex if ( $ record instanceof Individual && $ filtersx !== $ record -> sex ( ) ) { continue ; } // Can't display families if the sex filter is on. if ( $ record instanceof Family ) { continue ; } } // Filter living individuals if ( $ filterof === 'living' ) { if ( $ record instanceof Individual && $ record -> isDead ( ) ) { continue ; } if ( $ record instanceof Family ) { $ husb = $ record -> husband ( ) ; $ wife = $ record -> wife ( ) ; if ( $ husb && $ husb -> isDead ( ) || $ wife && $ wife -> isDead ( ) ) { continue ; } } } // Filter on recent events if ( $ filterof === 'recent' && $ fact -> date ( ) -> maximumJulianDay ( ) < $ hundred_years ) { continue ; } $ filtered [ ] = $ fact ; } return $ filtered ; }
Filter a list of anniversaries

@param Fact[] $facts
@param string $filterof
@param string $filtersx

@return Fact[]
Filter a list of anniversaries