seriesMode || !$this->startDate || !$this->endDate) { return []; } try { $timezone = auth()->user()->timezone ?? 'Europe/Berlin'; $startDate = \Carbon\Carbon::createFromFormat('Y-m-d H:i', $this->startDate . ' ' . $this->startTime, $timezone); $endDate = \Carbon\Carbon::createFromFormat('Y-m-d', $this->endDate, $timezone); $dates = []; $currentDate = $startDate->copy(); while ($currentDate->lessThanOrEqualTo($endDate) && count($dates) < 100) { $dates[] = [ 'date' => $currentDate->copy(), 'formatted' => $currentDate->translatedFormat('l, d.m.Y'), 'time' => $currentDate->format('H:i'), ]; if ($this->interval === 'weekly') { $currentDate->addWeek(); } else { $currentDate->addMonth(); } } return $dates; } catch (\Exception $e) { return []; } } #[Validate('required|string|max:255')] public ?string $location = null; #[Validate('required|string')] public ?string $description = null; #[Validate('required|url|max:255')] public ?string $link = null; public function mount(): void { $this->country = request()->route('country', config('app.domain_country')); $timezone = auth()->user()->timezone ?? 'Europe/Berlin'; if ($this->event) { $localStart = $this->event->start->setTimezone($timezone); $this->startDate = $localStart->format('Y-m-d'); $this->startTime = $localStart->format('H:i'); $this->location = $this->event->location; $this->description = $this->event->description; $this->link = $this->event->link; } else { // Set default start time to next Monday at 19:00 in user's timezone $defaultStart = now($timezone)->next('Monday')->setTime(19, 0); $this->startDate = $defaultStart->format('Y-m-d'); $this->startTime = $defaultStart->format('H:i'); $this->endDate = $defaultStart->copy()->addMonths(6)->format('Y-m-d'); } } public function save(): void { $validationRules = [ 'startDate' => 'required|date', 'startTime' => 'required', 'location' => 'required|string|max:255', 'description' => 'required|string', 'link' => 'required|url|max:255', ]; if ($this->seriesMode) { $validationRules['endDate'] = 'required|date|after:startDate'; $validationRules['interval'] = 'required|in:weekly,monthly'; } $this->validate($validationRules); $timezone = auth()->user()->timezone ?? 'Europe/Berlin'; if ($this->seriesMode && !$this->event) { // Create series of events $this->createEventSeries($timezone); } else { // Create or update single event $this->createOrUpdateSingleEvent($timezone); } $this->redirect(route('meetups.landingpage', ['meetup' => $this->meetup, 'country' => $this->country]), navigate: true); } private function createOrUpdateSingleEvent(string $timezone): void { // Combine date and time in user's timezone, then convert to UTC $localDateTime = \Carbon\Carbon::createFromFormat('Y-m-d H:i', $this->startDate . ' ' . $this->startTime, $timezone); $utcDateTime = $localDateTime->setTimezone('UTC'); $data = [ 'start' => $utcDateTime, 'location' => $this->location, 'description' => $this->description, 'link' => $this->link, ]; if ($this->event) { // Update existing event $this->event->update($data); session()->flash('status', __('Event erfolgreich aktualisiert!')); } else { // Create new event $this->meetup->meetupEvents()->create([ ...$data, 'created_by' => auth()->id(), 'attendees' => [], 'might_attendees' => [], ]); session()->flash('status', __('Event erfolgreich erstellt!')); } } private function createEventSeries(string $timezone): void { $startDate = \Carbon\Carbon::createFromFormat('Y-m-d H:i', $this->startDate . ' ' . $this->startTime, $timezone); $endDate = \Carbon\Carbon::createFromFormat('Y-m-d', $this->endDate, $timezone); $currentDate = $startDate->copy(); $eventsCreated = 0; while ($currentDate->lessThanOrEqualTo($endDate)) { $utcDateTime = $currentDate->copy()->setTimezone('UTC'); $this->meetup->meetupEvents()->create([ 'start' => $utcDateTime, 'location' => $this->location, 'description' => $this->description, 'link' => $this->link, 'created_by' => auth()->id(), 'attendees' => [], 'might_attendees' => [], ]); $eventsCreated++; // Move to next date based on interval if ($this->interval === 'weekly') { $currentDate->addWeek(); } else { $currentDate->addMonth(); } } session()->flash('status', __(':count Events erfolgreich erstellt!', ['count' => $eventsCreated])); } public function delete(): void { if ($this->event) { $this->event->delete(); session()->flash('status', __('Event erfolgreich gelöscht!')); $this->redirect(route('meetups.landingpage', ['meetup' => $this->meetup, 'country' => $this->country]), navigate: true); } } }; ?>
{{ $event ? __('Event bearbeiten') : __('Neues Event erstellen') }}: {{ $meetup->name }}
@if(!$event) {{ __('Serientermine erstellen') }} {{ __('Aktiviere diese Option, um mehrere Events mit regelmäßigen Abständen zu erstellen') }} @endif {{ __('Event Details') }}
{{ $seriesMode ? __('Startdatum') : __('Datum') }} * {{ $seriesMode ? __('Datum des ersten Termins') : __('An welchem Tag findet das Event statt?') }} {{ __('Uhrzeit') }} * {{ __('Um wie viel Uhr startet das Event?') }} ({{ auth()->user()->timezone ?? 'Europe/Berlin' }})
@if($seriesMode)
{{ __('Enddatum') }} * {{ __('Datum des letzten Termins') }} {{ __('Intervall') }} * {{ __('Wie oft soll das Event wiederholt werden?') }}
@endif {{ __('Ort') }} {{ __('Wo findet das Event statt?') }} {{ __('Beschreibung') }} {{ __('Details über das Event') }} {{ __('Link') }} {{ __('Link zu weiteren Informationen') }}
@if($seriesMode && count($this->previewDates) > 0)
{{ __('Vorschau der Termine') }} {{ count($this->previewDates) }} {{ __('Events') }}
@foreach($this->previewDates as $index => $dateInfo)
{{ $index + 1 }}
{{ $dateInfo['formatted'] }} {{ $dateInfo['time'] }} {{ __('Uhr') }}
@endforeach
@if(count($this->previewDates) >= 100) {{ __('Vorschau auf 100 Termine begrenzt. Es werden möglicherweise mehr Termine erstellt.') }} @endif
@endif
{{ __('Abbrechen') }} @if($event) {{ __('Event löschen') }} @endif
@if (session('status')) {{ session('status') }} @endif @if($seriesMode) {{ __('Serientermine erstellen') }} @else {{ $event ? __('Event aktualisieren') : __('Event erstellen') }} @endif
{{ __('Serientermine erstellen?') }} {{ __('Du bist dabei, mehrere Events zu erstellen.') }}
{{ __('Falsch angelegte Termine müssen alle händisch wieder gelöscht werden.') }}

{{ __('Bist du sicher, dass die Einstellungen korrekt sind?') }}
{{ __('Abbrechen') }} {{ __('Jetzt erstellen') }}