start event card content and add schedule method
This commit is contained in:
parent
c1a94e832f
commit
be549bba16
12 changed files with 102 additions and 11 deletions
25
site/models/event.php
Normal file
25
site/models/event.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
class EventPage extends Page {
|
||||
public function schedule() {
|
||||
$sessions = $this->isMapadoEvent() != 'true' ? $this->sessions()->toStructure() : $this->remoteSessions()->toStructure();
|
||||
|
||||
try {
|
||||
$firstSession = $sessions->first()->date();
|
||||
$lastSession = $sessions->last()->date();
|
||||
} catch (\Throwable $th) {
|
||||
throw new Exception('Can\'t define sessions for event "' . $this->title()->value() . '".', 1);
|
||||
}
|
||||
|
||||
$startDay = intval($firstSession->toDate('d'));
|
||||
$startMonth = $firstSession->toDate('MMMM');
|
||||
$endDay = intval($lastSession->toDate('d'));
|
||||
$endMonth = $lastSession->toDate('MMMM');
|
||||
|
||||
if ($firstSession->toDate('y-M') === $lastSession->toDate('y-M')) {
|
||||
return $startDay . ' - ' . $endDay . ' ' . $endMonth;
|
||||
} else {
|
||||
return $startDay . ' ' . $startMonth . ' - ' . $endDay . ' ' . $endMonth;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue