73 lines
2.6 KiB
PHP
73 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Mail\ParticipantRefundMails;
|
|
|
|
use App\Enumerations\RefundAccountSource;
|
|
use App\Models\EventParticipant;
|
|
use App\Models\ParticipantRefund;
|
|
use App\Support\Iban;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Mail\Mailables\Attachment;
|
|
use Illuminate\Mail\Mailables\Content;
|
|
use Illuminate\Mail\Mailables\Envelope;
|
|
|
|
/**
|
|
* Fordert den Teili auf, seine Bankverbindung für die freigegebene Erstattung zu hinterlegen.
|
|
*/
|
|
class RefundReleasedMail extends Mailable
|
|
{
|
|
public function __construct(
|
|
private EventParticipant $participant,
|
|
private ParticipantRefund $refund,
|
|
) {
|
|
}
|
|
|
|
public function envelope(): Envelope
|
|
{
|
|
return new Envelope(
|
|
subject: sprintf(
|
|
'Rückerstattung deines Beitrags für die Veranstaltung %s',
|
|
$this->participant->event()->first()->name
|
|
),
|
|
);
|
|
}
|
|
|
|
public function content(): Content
|
|
{
|
|
$event = $this->participant->event()->first();
|
|
|
|
return new Content(
|
|
view: 'emails.events.refund_released',
|
|
with: [
|
|
'name' => $this->participant->getNicename(),
|
|
'eventTitle' => $event->name,
|
|
'eventEmail' => $event->email,
|
|
'amount' => $this->refund->amount?->toString() ?? '0,00 Euro',
|
|
'reason' => $this->refund->reasonLabel(),
|
|
'reasonNote' => $this->refund->reason_note,
|
|
// Absolute URL: der Link muss aus jedem Postfach heraus funktionieren.
|
|
'link' => url('/rueckerstattung/' . $this->refund->token),
|
|
// Steht das Konto schon fest (aus dem Zahlungseingang), fragt die Mail nicht nach der
|
|
// Bankverbindung, sondern nur noch nach der Entscheidung auszahlen/spenden.
|
|
//
|
|
// Maskiert, aus demselben Grund wie auf der Seite: Diese Mail liegt in einem Postfach.
|
|
'knownAccountOwner' => $this->refund->account_owner,
|
|
'knownAccountIban' => $this->refund->account_iban === null
|
|
? null
|
|
: Iban::mask($this->refund->account_iban),
|
|
// Ohne Ursprungskonto (Barzahlung) wäre der Hinweis „nur auf das Konto, von dem gezahlt
|
|
// wurde" falsch -- dort ist stattdessen ein Konto auf den eigenen Namen gefragt.
|
|
'hasOriginAccount' => $this->participant->refundData()->source !== RefundAccountSource::None,
|
|
],
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @return array<int, Attachment>
|
|
*/
|
|
public function attachments(): array
|
|
{
|
|
return [];
|
|
}
|
|
}
|