request->event->firstParticipationFee(); if ($participationFee === null) { $response->message = 'Für diese Veranstaltung ist noch keine Teilnahmegruppe hinterlegt.'; return $response; } $participationType = $participationFee->type; // Nur hinterlegte Beitragsstufen sind wählbar -- für jede andere hätte calculateAmount() keinen Betrag. if (!in_array($this->request->feeType, $participationFee->availableFeeTypes(), true)) { $response->message = 'Der gewählte Beitrag ist für diese Veranstaltung nicht verfügbar.'; return $response; } $participantAge = new Age($this->request->birthday); // Bei Minderjährigen ist die Kontaktperson Pflicht; der Client prüft das ebenfalls, verlassen wird sich // darauf nicht. if (!$participantAge->isfullAged() && ($this->request->contactPerson === null || $this->request->contactEmail === null)) { $response->message = 'Für Minderjährige werden Name und E-Mail-Adresse einer Kontaktperson benötigt.'; return $response; } // Stamm: bei genau einem teilnehmenden Stamm wird dieser gesetzt, bei mehreren muss gewählt werden, // ohne teilnehmende Stämme bleibt die Zuordnung leer. $localGroups = $this->request->event->localGroups; $localGroup = null; if ($localGroups->count() === 1) { $localGroup = $localGroups->first(); } elseif ($localGroups->count() > 1) { $localGroup = $localGroups->firstWhere('id', $this->request->localGroupId); if ($localGroup === null) { $response->message = 'Bitte einen Stamm auswählen.'; return $response; } } $eventResource = $this->request->event->toResource(); // Zeitraum und Gruppe stehen bei der Kurzanmeldung fest, wählbar ist nur die Beitragsstufe. $amount = $eventResource->calculateAmount( $participationType, $this->request->feeType, $this->request->event->start_date, $this->request->event->end_date, false ); $signUpRequest = new SignUpRequest( event: $this->request->event, user_id: $this->request->user_id, firstname: $this->request->firstname, lastname: $this->request->lastname, nickname: $this->request->nickname, participationType: $participationType, localGroup: $localGroup, birthday: $this->request->birthday, address_1: self::PLACEHOLDER, address_2: null, postcode: self::PLACEHOLDER_POSTCODE, city: self::PLACEHOLDER, email_1: $this->request->email, phone_1: $this->request->phone, email_2: $this->request->contactEmail, phone_2: null, contact_person: $this->request->contactPerson, allergies: $this->request->allergies, intolerances: $this->request->intolerances, medications: null, tetanus_vaccination: null, // Kein Wert der Zuordnung -- der SignUpCommand fällt damit auf "Omnivor" zurück. eating_habit: '', swimming_permission: $this->resolveSwimmingPermission($participantAge), first_aid_permission: $participantAge->isfullAged() ? '-1' : ($this->request->firstAidPermission ?? '-1'), foto_socialmedia: $this->request->foto_socialmedia, foto_print: $this->request->foto_print, foto_webseite: $this->request->foto_webseite, foto_partner: $this->request->foto_partner, foto_intern: $this->request->foto_intern, arrival: $this->request->event->start_date, departure: $this->request->event->end_date, arrival_eating: 1, departure_eating: 2, notes: null, amount: $amount, paymentMethod: $this->request->paymentMethod, paymentOptions: $this->request->paymentOptions, participationOptions: $this->request->participationOptions, addonItems: [], feeType: $this->request->feeType, siblingReduction: false, ); $signUpResponse = new SignUpCommand($signUpRequest)->execute(); $response->success = $signUpResponse->success; $response->participant = $signUpResponse->participant; $response->message = $signUpResponse->message; return $response; } /** * Bei Volljährigen und wenn die Veranstaltung die Badeerlaubnis nicht abfragt, entscheidet der SignUpCommand * (volljährig => erteilt, nicht abgefragt => keine). Nur die getroffene Auswahl Minderjähriger wird * durchgereicht. */ private function resolveSwimmingPermission(Age $participantAge) : ?string { if ($participantAge->isfullAged() || !$this->request->event->swimming_permission_required) { return null; } return $this->request->swimmingPermission; } }