Event addons bookable

This commit is contained in:
2026-08-12 16:45:02 +02:00
parent e95de52768
commit 0ee952212b
25 changed files with 656 additions and 24 deletions
@@ -77,11 +77,45 @@ class UpdateParticipantCommand {
$this->syncParticipationOptions($p);
}
if ($this->request->selectedAddons !== null) {
$this->syncAddons($p);
}
$this->response->success = true;
$this->response->participant = $p;
return $this->response;
}
/**
* 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
* Snapshot gespeichert, damit die Zuordnung sichtbar bleibt.
*/
private function syncAddons(EventParticipant $participant): void
{
$participant->selectedAddons()->delete();
$selection = $this->request->selectedAddons ?? [];
foreach ($participant->event?->addons ?? [] as $addon) {
$key = $addon['key'] ?? null;
if ($key === null || empty($selection[$key])) {
continue;
}
$participant->selectedAddons()->create([
'tenant' => $participant->tenant,
'event_id' => $participant->event_id,
'addon_key' => $key,
'title' => $addon['title'] ?? $key,
'price' => 0,
'flat' => (bool)($addon['flat'] ?? false),
'days' => 0,
'amount' => 0,
]);
}
}
/**
* Ersetzt die zugeordneten Teilnahmeoptionen anhand der übergebenen Antworten. Nachträgliche Zuordnung im
* Back-Office ist lückenlos möglich: nur gegen die Event-Definition gültige Antworten werden gespeichert,
@@ -38,5 +38,7 @@ class UpdateParticipantRequest {
public string $cocStatus,
/** Antworten auf die Teilnahmeoptionen: [ question_key => value ]. null = unverändert lassen. */
public ?array $participationOptions = null,
/** Gewählte Zusätze: [ addon_key => bool ]. null = unverändert lassen. */
public ?array $selectedAddons = null,
) {}
}