'date',
'tetanus_vaccination' => 'date',
'arrival_date' => 'date',
'departure_date' => 'date',
'unregistered_at' => 'date',
'foto_socialmedia' => 'boolean',
'foto_print' => 'boolean',
'foto_webseite' => 'boolean',
'foto_partner' => 'boolean',
'foto_intern' => 'boolean',
'amount' => AmountCast::class,
'amount_paid' => AmountCast::class,
];
/*
|--------------------------------------------------------------------------
| Relationships
|--------------------------------------------------------------------------
*/
public function event()
{
return $this->belongsTo(Event::class);
}
public function user()
{
return $this->belongsTo(User::class);
}
public function tenantRelation()
{
return $this->belongsTo(Tenant::class, 'tenant', 'slug');
}
public function localGroup()
{
return $this->belongsTo(Tenant::class, 'local_group', 'slug');
}
public function participationType()
{
return $this->belongsTo(ParticipationType::class, 'participation_type', 'slug');
}
public function swimmingPermission()
{
return $this->belongsTo(SwimmingPermission::class, 'swimming_permission', 'slug');
}
public function eatingHabit()
{
return $this->belongsTo(EatingHabit::class, 'eating_habits', 'slug');
}
public function paymentMethod()
{
return $this->belongsTo(\App\Models\PaymentMethod::class, 'payment_method', 'slug');
}
public function firstAidPermission()
{
return $this->belongsTo(FirstAidPermission::class, 'first_aid_permission', 'slug');
}
public function efzStatus()
{
return $this->belongsTo(EfzStatus::class, 'efz_status', 'slug');
}
public function getOfficialName() : string {
return sprintf('%1$s %2$s', $this->firstname, $this->lastname);
}
public function getFullName() : string {
if ($this->nickname === null || trim($this->nickname) === '') {
return sprintf('%1$s %2$s', $this->firstname, $this->lastname)
|>trim(...);
}
return sprintf('%1$1s%2$s(%3$s %4$s)',
$this->nickname,
'
',
$this->firstname,
$this->lastname,
)
|>trim(...);
}
public function getNicename() : string {
return $this->nickname ?? $this->firstname;
}
/*
|--------------------------------------------------------------------------
| Zahlungsmodul
|--------------------------------------------------------------------------
*/
/** Das Zahlungsmodul der gewählten Zahlungsart des Teilnehmers. */
public function paymentModule(): ?EventPaymentModule
{
return $this->payment_method !== null
? EventPaymentModuleRegistry::forSlug($this->payment_method)
: null;
}
/**
* Aufgelöste pro-Event-Konfiguration der gewählten Zahlungsart (event_payment_methods.configuration).
*
* Nutzt die Relation-Property, damit sie via `->with('event.paymentMethods')` eager geladen und in
* Teilnehmerlisten (gleiches Event teilt dieselbe Event-Instanz) ohne N+1 aufgelöst werden kann.
*
* @return array
*/
public function paymentConfiguration(): array
{
if ($this->payment_method === null) {
return [];
}
$method = $this->event?->paymentMethods->firstWhere('slug', $this->payment_method);
return $method?->pivot->configuration ?? [];
}
/** Zahlungs-Zusammenfassung (Anmeldeabschluss/Mail), vom Zahlungsmodul erzeugt. */
public function paymentSummary(): RegistrationSummaryResponse
{
$module = $this->paymentModule();
if ($module === null) {
return new RegistrationSummaryResponse();
}
return $module->registrationSummary(new RegistrationSummaryRequest($this, $this->paymentConfiguration()));
}
}