Hi
I’m trying to filter my events based on a date field. I want to show only events in the future. With the ->filterBy('date', '>', time())
that works just great.
But my problem is that if the event has an enddate, I want to hide it after that date. But not after the startdate. And the enddate is only filled in, if the event lasts more than one day. So on regular one-day-events there is no enddate but only a startdate.
I also tried with a filter function
$page
->children()
->visible()
->filter(function($child) {
if($child->dateend()->isEmpty()):
return $child->date() > time();
else:
return $child->dateend() > time();
endif;
})
->sortBy('date', 'asc');
But it doesn’t seem to work. I’m sorry for my very basic PHP-skills.