Creating Participation refunds
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\ParticipantRefund\Controllers;
|
||||
|
||||
use App\Domains\ParticipantRefund\Actions\CancelRefund\CancelRefundCommand;
|
||||
use App\Domains\ParticipantRefund\Actions\CancelRefund\CancelRefundRequest;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CancelRefundController extends CommonController
|
||||
{
|
||||
public function __invoke(string $refundToken, Request $request): JsonResponse
|
||||
{
|
||||
$refund = $this->participantRefunds->getByToken($refundToken);
|
||||
|
||||
// Der Token ist hier keine Berechtigung: abbrechen darf nur, wer die Veranstaltung auch
|
||||
// verwalten kann. `getById()` prüft genau das.
|
||||
if ($refund === null || $this->events->getById($refund->event_id) === null) {
|
||||
abort(403, 'Zugriff verweigert.');
|
||||
}
|
||||
|
||||
$response = new CancelRefundCommand(new CancelRefundRequest($refund))->execute();
|
||||
|
||||
return response()->json([
|
||||
'status' => $response->success ? 'success' : 'error',
|
||||
'message' => $response->message,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user