Files
mareike/app/Repositories/ParticipantRefundRepository.php

42 lines
1.5 KiB
PHP

<?php
namespace App\Repositories;
use App\Models\EventParticipant;
use App\Models\ParticipantRefund;
class ParticipantRefundRepository
{
/** Der offene Vorgang einer Anmeldung -- es kann höchstens einen geben. */
public function openFor(EventParticipant $participant): ?ParticipantRefund
{
return ParticipantRefund::where('event_participant_id', $participant->id)
->where('status', ParticipantRefund::STATUS_PENDING)
->first();
}
/**
* Der für die Anzeige maßgebliche Vorgang: der offene, sonst der zuletzt bestätigte. Abgebrochene
* Vorgänge bleiben außen vor -- für die Aktionsleitung sieht die Anmeldung danach aus wie vorher.
*/
public function currentFor(EventParticipant $participant): ?ParticipantRefund
{
return ParticipantRefund::where('event_participant_id', $participant->id)
->whereIn('status', [ParticipantRefund::STATUS_PENDING, ParticipantRefund::STATUS_ACCEPTED])
->orderByDesc('id')
->first();
}
/**
* Der Vorgang zu einem öffentlichen Link.
*
* Der Token ist die einzige Autorisierung -- dasselbe Modell wie bei /print-girocode/{identifier}.
* Der Mandant kommt über den globalen SiteScope aus dem Host der Anfrage: ein Token einer anderen
* Instanz findet hier nichts.
*/
public function getByToken(string $token): ?ParticipantRefund
{
return ParticipantRefund::where('token', $token)->first();
}
}