Implemented additional event information

This commit is contained in:
2026-08-12 15:54:00 +02:00
parent 9581176a0c
commit e95de52768
16 changed files with 327 additions and 22 deletions
@@ -72,11 +72,63 @@ class UpdateParticipantCommand {
$p->save();
if ($this->request->participationOptions !== null) {
$this->syncParticipationOptions($p);
}
$this->response->success = true;
$this->response->participant = $p;
return $this->response;
}
/**
* 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,
* leere/entfallene Antworten werden abgeräumt. Frage-/Options-Label werden als Snapshot mitgeschrieben.
*/
private function syncParticipationOptions(EventParticipant $participant): void
{
$participant->selectedOptions()->delete();
$answers = $this->request->participationOptions ?? [];
foreach ($participant->event?->participation_options ?? [] as $question) {
$key = $question['key'] ?? null;
if ($key === null) {
continue;
}
$value = $answers[$key] ?? null;
if ($value === null || $value === '') {
continue;
}
$option = null;
foreach ($question['options'] ?? [] as $candidate) {
if (($candidate['value'] ?? null) === $value) {
$option = $candidate;
break;
}
}
if ($option === null) {
continue;
}
$label = trim((string)($question['label'] ?? ''));
$participant->selectedOptions()->create([
'tenant' => $participant->tenant,
'event_id' => $participant->event_id,
'question_key' => $key,
'question_label' => $label !== '' ? $label : ($question['title'] ?? $key),
'value' => $value,
'value_label' => $option['label'] ?? $value,
]);
}
}
private function handleAmountChanges(EventParticipant $participant) {
$this->response->amountPaid = $participant->amount_paid;
$this->response->amountExpected = $participant->amount;