Support oft parent groups
This commit is contained in:
@@ -31,9 +31,8 @@ class UpdateParticipantCommand {
|
||||
$p->address_2 = $this->request->address_2;
|
||||
$p->postcode = $this->request->postcode;
|
||||
$p->city = $this->request->city;
|
||||
// Leerer String würde als Fremdschlüssel scheitern -- kein Stamm heißt null.
|
||||
$p->local_group = $this->request->localgroup ?: null;
|
||||
$p->birthday = DateTime::createFromFormat('Y-m-d', $this->request->birthday);
|
||||
$this->applyParticipantGroup($p);
|
||||
$p->birthday = DateTime::createFromFormat('Y-m-d', $this->request->birthday);
|
||||
$p->email_1 = $this->request->email_1;
|
||||
$p->phone_1 = $this->request->phone_1;
|
||||
$p->contact_person = $this->request->contact_person;
|
||||
@@ -87,6 +86,29 @@ class UpdateParticipantCommand {
|
||||
return $this->response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Übernimmt die gewählte Gruppe -- je nach Veranstaltung die Local Group (Slug) oder die Parent Group (ID).
|
||||
* Angenommen wird nur, was die Veranstaltung zur Auswahl stellt; leer heißt keine Angabe (null, ein leerer
|
||||
* String würde als Fremdschlüssel scheitern).
|
||||
*/
|
||||
private function applyParticipantGroup(EventParticipant $participant): void
|
||||
{
|
||||
$event = $participant->event;
|
||||
$value = trim((string) $this->request->participantGroup);
|
||||
|
||||
if ($event->asksForParentGroup()) {
|
||||
$participant->parent_group_id = $value === ''
|
||||
? null
|
||||
: $event->participantGroupOptions()->firstWhere('id', (int) $value)?->id;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$participant->local_group = $value === ''
|
||||
? null
|
||||
: $event->participantGroupOptions()->firstWhere('slug', $value)?->slug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ersetzt die zugeordneten Zusätze (Event-Addons) anhand der Auswahl. Bewusst **ohne Preis/Betrag**
|
||||
* (amount 0): der Teilnahmebeitrag wird in den Details ohnehin manuell gesetzt. Es wird nur der Titel als
|
||||
|
||||
Reference in New Issue
Block a user