Teilnahmerechnungen erstellen
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\ParticipantInvoice\Controllers;
|
||||
|
||||
use App\Domains\ParticipantInvoice\Actions\CreateParticipantInvoice\CreateParticipantInvoiceCommand;
|
||||
use App\Domains\ParticipantInvoice\Actions\CreateParticipantInvoice\CreateParticipantInvoiceRequest;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class CreateParticipantInvoiceController extends CommonController
|
||||
{
|
||||
public function __invoke(string $participantIdentifier): Response
|
||||
{
|
||||
$participant = $this->eventParticipants->getByIdentifier($participantIdentifier, $this->events);
|
||||
|
||||
if ($participant === null) {
|
||||
abort(403, 'Zugriff verweigert.');
|
||||
}
|
||||
|
||||
$invoiceRequest = new CreateParticipantInvoiceRequest($participant);
|
||||
$invoiceCommand = new CreateParticipantInvoiceCommand($invoiceRequest);
|
||||
$invoiceResponse = $invoiceCommand->execute();
|
||||
|
||||
if (!$invoiceResponse->success) {
|
||||
abort(422, $invoiceResponse->message ?? 'Die Rechnung konnte nicht erstellt werden.');
|
||||
}
|
||||
|
||||
return response($invoiceResponse->pdfContent, 200, [
|
||||
'Content-Type' => 'application/pdf',
|
||||
'Content-Disposition' => 'attachment; filename="' . $invoiceResponse->filename . '"',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user