Kurzanmeldungen
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Event\Controllers;
|
||||
|
||||
use App\Scopes\CommonController;
|
||||
use App\ValueObjects\Amount;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
/**
|
||||
* Beitrag einer Kurzanmeldung. Teilnahmegruppe, Beitragsstufe und Zeitraum stehen fest, deshalb braucht der
|
||||
* Endpunkt keine Eingaben -- und der Betrag lässt sich vom Client nicht beeinflussen.
|
||||
*
|
||||
* `amountValue` steuert im Frontend, ob der Schritt "Zahlungsart" gezeigt wird.
|
||||
*/
|
||||
class ShortCalculateAmountController extends CommonController {
|
||||
public function __invoke(int $eventId) : JsonResponse {
|
||||
$event = $this->events->getById($eventId, false);
|
||||
|
||||
$participationType = $event->firstParticipationTypeSlug();
|
||||
|
||||
$amount = $participationType === null
|
||||
? new Amount(0, 'Euro')
|
||||
: $event->toResource()->calculateAmount(
|
||||
$participationType,
|
||||
'standard',
|
||||
$event->start_date,
|
||||
$event->end_date,
|
||||
false
|
||||
);
|
||||
|
||||
return response()->json([
|
||||
'amount' => $amount->toString(),
|
||||
'amountValue' => $amount->getAmount(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user