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; } } }