diff --git a/site/models/event.php b/site/models/event.php new file mode 100644 index 0000000..e02ccce --- /dev/null +++ b/site/models/event.php @@ -0,0 +1,26 @@ +dates()->toStructure()->data()); + + usort($groups, fn($a, $b) => strcmp( + $this->firstDateOf($a), + $this->firstDateOf($b) + )); + + 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) : ''; + } +}