request = $request; } public function execute() : UpdateEventResponse { $response = new UpdateEventResponse(); $this->request->event->name = $this->request->eventName; $this->request->event->location = $this->request->eventLocation; $this->request->event->street = $this->normalizeOptional($this->request->street); $this->request->event->house_number = $this->normalizeOptional($this->request->houseNumber); $this->request->event->postal_code = $this->request->postalCode; $this->request->event->email = $this->request->email; $this->request->event->early_bird_end = $this->request->earlyBirdEnd; $this->request->event->registration_final_end = $this->request->registrationFinalEnd; $this->request->event->alcoholics_age = $this->request->alcoholicsAge; $this->request->event->support_per_person = $this->request->supportPerPerson; $this->request->event->support_flat = $this->request->flatSupport; $this->request->event->send_weekly_report = $this->request->sendWeeklyReports; $this->request->event->registration_allowed = $this->request->registrationAllowed; $this->request->event->short_registration = $this->request->shortRegistration; $this->request->event->swimming_permission_required = $this->request->swimmingPermissionRequired; $this->request->event->save(); $this->request->event->resetAllowedEatingHabits(); $this->request->event->resetContributingLocalGroups(); foreach($this->request->eatingHabits as $eatingHabit) { $this->request->event->eatingHabits()->attach($eatingHabit); } foreach($this->request->contributingLocalGroups as $contributingLocalGroup) { $this->request->event->localGroups()->attach($contributingLocalGroup); } $this->request->event->save(); $response->success = true; return $response; } /** * Straße und Hausnummer sind optional. Ein geleertes Eingabefeld liefert einen leeren String -- * gespeichert wird dafür `null`, damit „nicht angegeben" nur eine Darstellung hat. */ private function normalizeOptional(?string $value): ?string { $value = trim((string) $value); return '' === $value ? null : $value; } }