Moved bank transfer logic to special module
This commit is contained in:
@@ -8,8 +8,11 @@ use App\Enumerations\EfzStatus;
|
||||
use App\Enumerations\FirstAidPermission;
|
||||
use App\Enumerations\ParticipationType;
|
||||
use App\Enumerations\SwimmingPermission;
|
||||
use App\EventPaymentModules\DTO\RegistrationSummaryRequest;
|
||||
use App\EventPaymentModules\DTO\RegistrationSummaryResponse;
|
||||
use App\EventPaymentModules\EventPaymentModule;
|
||||
use App\EventPaymentModules\EventPaymentModuleRegistry;
|
||||
use App\Scopes\InstancedModel;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
|
||||
class EventParticipant extends InstancedModel
|
||||
@@ -166,4 +169,47 @@ class EventParticipant extends InstancedModel
|
||||
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<string, mixed>
|
||||
*/
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user