So far I have a PageMethod that returns future events. It looks something like this:
public function upcomingEvents() {
$events = $this->children()->listed()->filter(function($child){
return $child->hasUpcomingDate();
})->sortBy('nearestDate', 'asc');
return $events;
}
I now need the filter directly on the overview panel, so moving it to a siteMethod seemed to make sense so that I can also filter the events here.
This is now part of the config. However, it does not seem to work. What could be the problem?
'siteMethods' => [
'upcomingEvents' => function() {
$events = kirby()->site()->children()->listed()->filter(function($child){
return $child->hasUpcomingDate();
})->sortBy('nearestDate', 'asc');
return $events;
}
]