Payment reminder mails

This commit is contained in:
2026-04-18 22:09:57 +02:00
parent ff98f0860c
commit 33a9271013
13 changed files with 157 additions and 10 deletions

View File

@@ -0,0 +1,37 @@
<?php
namespace App\Domains\Event\Actions\SendMissingPaymentMails;
use App\Mail\ParticipantPaymentMails\ParticipantPaymentMissingPaymentMail;
use Illuminate\Support\Facades\Mail;
class SendMissingPaymentMailsCommand {
function __construct(public SendMissingPaymentMailsRequest $request) {}
public function execute() : SendMissingPaymentMailsResponse {
$response = new SendMissingPaymentMailsResponse();
foreach ($this->request->eventParticipants->getParticipantsWithMissingPayments($this->request->event, $this->request->httpRequest) as $participant) {
$participantResource = $participant->toResource()->toArray($this->request->httpRequest);
if (!$participantResource['needs_payment']) {
continue;
}
Mail::to($participant->email_1)->send(new ParticipantPaymentMissingPaymentMail(
participant: $participant,
));
if ($participant->email_2 !== null && $participant->email_2 !== $participant->email_1) {
Mail::to($participant->email_2)->send(new ParticipantPaymentMissingPaymentMail(
participant: $participant,
));
}
$response->remindedParticipants++;
}
$response->success = true;
return $response;
}
}

View File

@@ -0,0 +1,16 @@
<?php
namespace App\Domains\Event\Actions\SendMissingPaymentMails;
use App\Models\Event;
use App\Repositories\EventParticipantRepository;
use Illuminate\Http\Request;
class SendMissingPaymentMailsRequest {
function __construct(
public Event $event,
public EventParticipantRepository $eventParticipants,
public Request $httpRequest
) {
}
}

View File

@@ -0,0 +1,10 @@
<?php
namespace App\Domains\Event\Actions\SendMissingPaymentMails;
class SendMissingPaymentMailsResponse {
function __construct(
public bool $success = false,
public int $remindedParticipants = 0
) {}
}