GUI for Participant management

This commit is contained in:
2026-04-07 22:27:47 +02:00
parent 653e85b781
commit e6bd8c684d
20 changed files with 965 additions and 153 deletions

View File

@@ -2,6 +2,8 @@
namespace App\Resources;
use App\Enumerations\EatingHabit;
use App\Enumerations\EfzStatus;
use App\Enumerations\ParticipationType;
use App\Models\EventParticipant;
use App\ValueObjects\Age;
@@ -18,7 +20,7 @@ class EventParticipantResource extends JsonResource
{
$event = $this->resource->event;
$amountLeft = $this->resource->amount;
$amountLeft = clone $this->resource->amount;
if ($this->resource->amount_paid !== null) {
$amountLeft->subtractAmount($this->resource->amount_paid);
}
@@ -32,14 +34,20 @@ class EventParticipantResource extends JsonResource
$presenceDaysSupport = $presenceDaysSupport - 1;
}
return array_merge(
$this->resource->toArray(),
[
'birthdayDate' => $this->resource->birthday->format('Y-m-d'),
'registerDate' => $this->resource->created_at->format('d.m.Y'),
'fullname' => $this->resource->getFullName(),
'age' => new Age($this->resource->birthday)->getAge(),
'localgroup' => $this->resource->localGroup()->first()->name,
'swimmingPermission' => $this->resource->swimmingPermission()->first()->short,
'extendedFirstAid' => $this->resource->firstAidPermission()->first()->name,
'tetanusVaccination' => $this->resource->tetanus_vaccination?->format('d.m.Y'),
'tetanusVaccination' => $this->resource->tetanus_vaccination?->format('d.m.Y') ?? 'Unbekannt',
'presenceDays' => ['real' => $presenceDays, 'support' => $presenceDaysSupport],
'participationType' => ParticipationType::where(['slug' => $this->resource->participation_type])->first()->name,
'needs_payment' => $this->resource->amount->getAmount() > 0 && $event->pay_direct,
@@ -49,14 +57,21 @@ class EventParticipantResource extends JsonResource
'amount_left_string' => $amountLeft->toString(),
'amount_left_value' => $amountLeft->getAmount(),
'email_1' => $this->resource->email_1,
'amountPaid' => ['value' => $this->resource->amount_paid, 'readable' => $this->resource->amount_paid?->toString() ?? '0,00 Euro'],
'amountExpected' => ['value' => $this->resource->amount, 'readable' => $this->resource->amount?->toString() ?? '0,00 Euro'],
'amountPaid' => ['value' => $this->resource->amount_paid, 'readable' => $this->resource->amount_paid?->toString() ?? '0,00 Euro', 'short' => $this->resource->amount_paid?->getFormattedAmount() ?? '0,00'],
'amountExpected' => ['value' => $this->resource->amount, 'readable' => $this->resource->amount?->toString() ?? '0,00 Euro', 'short' => $this->resource->amount?->getFormattedAmount() ?? '0,00'],
'alcoholicsAllowed' => new Age($this->resource->birthday)->getAge() >= $event->alcoholics_age,
'localGroupPostcode' => $this->resource->localGroup()->first()->postcode,
'localGroupCity' => $this->resource->localGroup()->first()->city,
'state' => config('postCode.map.' . $this->resource->postcode),
'localGroupState' => config('postCode.map.' . $this->resource->localGroup()->first()->postcode),
'birthday' => $this->resource->birthday->format('d.m.Y'),
'eatingHabit' => EatingHabit::where('slug', $this->resource->eating_habit)->first()->name,
'efzStatusReadable' => match($this->resource->efz_status) {
EfzStatus::EFZ_STATUS_CHECKED_VALID => 'Gültig',
EfzStatus::EFZ_STATUS_CHECKED_INVALID => 'Ungültig',
EfzStatus::EFZ_STATUS_NOT_CHECKED => 'Nicht geprüft',
EfzStatus::EFZ_STATUS_NOT_REQUIRED => 'Nicht erforderlich',
},
]
);
}

View File

@@ -17,6 +17,7 @@ class LocalGroupResource extends JsonResource {
'email' => $this->resource->email,
'city' => $this->resource->city,
'postalcode' => $this->resource->postcode,
'slug' => $this->resource->slug,
];
}
}