Switch dates to from/to range, sort by most recent end date
This commit is contained in:
parent
03099845a8
commit
7e6854da22
2 changed files with 16 additions and 22 deletions
|
|
@ -7,20 +7,10 @@ class EventPage extends Page
|
|||
$groups = array_values($this->dates()->toStructure()->data());
|
||||
|
||||
usort($groups, fn($a, $b) => strcmp(
|
||||
$this->firstDateOf($a),
|
||||
$this->firstDateOf($b)
|
||||
$b->to()->value() ?? '',
|
||||
$a->to()->value() ?? ''
|
||||
));
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
private function firstDateOf($group): string
|
||||
{
|
||||
$dates = array_filter(array_map(
|
||||
fn($item) => $item->date()->value(),
|
||||
array_values($group->dates()->toStructure()->data())
|
||||
));
|
||||
|
||||
return !empty($dates) ? min($dates) : '';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue