country = request()->route('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'); } } public function save(): void { $this->validate([ 'startDate' => 'required|date', 'startTime' => 'required', 'location' => 'required|string|max:255', 'description' => 'required|string', 'link' => 'required|url|max:255', ]); $timezone = auth()->user()->timezone ?? 'Europe/Berlin'; // 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!')); } $this->redirect(route('meetups.landingpage', ['meetup' => $this->meetup, 'country' => $this->country]), navigate: true); } 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 }}
{{ __('Event Details') }}
{{ __('Datum') }} * {{ __('An welchem Tag findet das Event statt?') }} {{ __('Uhrzeit') }} * {{ __('Um wie viel Uhr startet das Event?') }} ({{ auth()->user()->timezone ?? 'Europe/Berlin' }})
{{ __('Ort') }} {{ __('Wo findet das Event statt?') }} {{ __('Beschreibung') }} {{ __('Details über das Event') }} {{ __('Link') }} {{ __('Link zu weiteren Informationen') }}
{{ __('Abbrechen') }} @if($event) {{ __('Event löschen') }} @endif
@if (session('status')) {{ session('status') }} @endif {{ $event ? __('Event aktualisieren') : __('Event erstellen') }}