Support oft parent groups
This commit is contained in:
@@ -51,7 +51,12 @@ class EventParticipantResource extends JsonResource
|
||||
'unregisteredAt' => $this->resource->unregistered_at?->format('d.m.Y'),
|
||||
'fullname' => $this->resource->getFullName(),
|
||||
'age' => new Age($this->resource->birthday)->getAge(),
|
||||
'localgroup' => $this->resource->localGroup()?->first()?->name ?? 'Nicht im LV',
|
||||
// Die bei der Anmeldung gewählte Gruppe: Local Group oder Parent Group, je nach Veranstaltung.
|
||||
'participantGroup' => $this->resource->participantGroupName($event),
|
||||
// Wert für die Auswahl in der Verwaltung: Slug der Local Group bzw. ID der Parent Group.
|
||||
'participantGroupValue' => $event->asksForParentGroup()
|
||||
? ($this->resource->parent_group_id !== null ? (string) $this->resource->parent_group_id : '')
|
||||
: ($this->resource->local_group ?? ''),
|
||||
// Die Zuordnungen sind nullable: die Kurzanmeldung erhebt nicht alles, und in der Verwaltung
|
||||
// lassen sich Werte leeren. Ohne Fallback fielen Teilnehmerliste und Detailansicht komplett aus.
|
||||
'swimmingPermission' => $this->resource->swimmingPermission()->first()?->short ?? 'Unbekannt',
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Enumerations\ParticipationFeeType;
|
||||
use App\Enumerations\ParticipationType;
|
||||
use App\Enumerations\VatPricingMode;
|
||||
use App\Models\Event;
|
||||
use App\Models\ParentGroup;
|
||||
use App\Support\DateRange;
|
||||
use App\ValueObjects\Amount;
|
||||
use DateTime;
|
||||
@@ -149,6 +150,19 @@ class EventResource extends JsonResource{
|
||||
$returnArray['contributingLocalGroups'] = $this->event->localGroups
|
||||
->map(fn ($localGroup) => new LocalGroupResource($localGroup)->toArray($request))
|
||||
->toArray();
|
||||
// Wonach bei der Anmeldung gefragt wird (Local oder Parent Group), mit Bezeichnung und Auswahl.
|
||||
// `id` wird bei der Anmeldung übermittelt, `value` ist der in der Verwaltung gepflegte Wert
|
||||
// (Slug der Local Group bzw. ID der Parent Group).
|
||||
$returnArray['participantGroupType'] = $this->event->participantGroupType()->value;
|
||||
$returnArray['participantGroupLabel'] = $this->event->participantGroupType()->label();
|
||||
$returnArray['participantGroupOptions'] = $this->event->participantGroupOptions()
|
||||
->map(fn ($group) => [
|
||||
'id' => $group->id,
|
||||
'name' => $group->name,
|
||||
'value' => $group instanceof ParentGroup ? (string) $group->id : $group->slug,
|
||||
])
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
$returnArray['eatingHabits'] = $this->event->eatingHabits()->get()->map(
|
||||
fn($eatingHabit) => new EatingHabitResource($eatingHabit))->toArray();
|
||||
|
||||
Reference in New Issue
Block a user