Hello everyone !
I wish to filter my events page by 2 parameters:
- show events that happen after today (starting from tomorrow)
- show events that happen only during the next 7 days (remove events that happen after the next 7 days)
The function I wrote already filter the events of today off - I just need to add a filter to show events that happen only in the next 7 days, this is my code right now:
<?php $today = date('Y-m-d'); $events = page()->children()->template('event') ->filter(fn ($p) => $p->date()->toDate('Y-m-d') > $today); $sortedEvents = $events->sortBy('date','starts'); foreach($sortedEvents as $event): ?> <?php snippet('event', ['event'=>$event])?> <?php endforeach ?>
Thanks in advance!