isMapadoEvent() != 'true' ? $this->sessions()->toStructure() : $this->remoteSessions()->toStructure(); if ($sessions->isEmpty()) { return ''; } 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'); $isSameMonth = $firstSession->toDate('y-M') === $lastSession->toDate('y-M'); $isSameDay = $firstSession->toDate('d') === $lastSession->toDate('d'); if ($isSameMonth) { if ($isSameDay) { return $startDay . ' ' . $endMonth; } else { return $startDay . ' - ' . $endDay . ' ' . $endMonth; } } else { return $startDay . ' ' . $startMonth . ' - ' . $endDay . ' ' . $endMonth; } } }