Files
mareike/app/Domains/Event/Controllers/BankStatementBookController.php
T
2026-09-09 16:55:08 +02:00

38 lines
1.3 KiB
PHP

<?php
namespace App\Domains\Event\Controllers;
use App\Domains\Event\Actions\BookBankStatementPayments\BookBankStatementPaymentsCommand;
use App\Domains\Event\Actions\BookBankStatementPayments\BookBankStatementPaymentsRequest;
use App\Scopes\CommonController;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
/**
* Bucht die in der Prüfansicht bestätigten Zahlungseingänge -- ein Aufruf für alle Zeilen.
*/
class BankStatementBookController extends CommonController
{
public function __invoke(int $eventId, Request $request): JsonResponse
{
$event = $this->events->getById($eventId);
if ($event === null) {
return response()->json(['status' => 'error', 'message' => 'Die Veranstaltung wurde nicht gefunden.']);
}
$response = new BookBankStatementPaymentsCommand(new BookBankStatementPaymentsRequest(
event: $event,
bookings: (array) $request->input('bookings', []),
))->execute();
return response()->json([
'status' => $response->success ? 'success' : 'error',
'message' => $response->message,
'booked' => $response->booked,
'skipped' => $response->skipped,
'failed' => $response->failed,
]);
}
}