-
-
Notifications
You must be signed in to change notification settings - Fork 635
Expand file tree
/
Copy pathGetPlatformFeePreviewAction.php
More file actions
38 lines (30 loc) · 1.11 KB
/
GetPlatformFeePreviewAction.php
File metadata and controls
38 lines (30 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
namespace HiEvents\Http\Actions\EventSettings;
use HiEvents\DomainObjects\EventDomainObject;
use HiEvents\Http\Actions\BaseAction;
use HiEvents\Resources\Event\PlatformFeePreviewResource;
use HiEvents\Services\Application\Handlers\EventSettings\DTO\GetPlatformFeePreviewDTO;
use HiEvents\Services\Application\Handlers\EventSettings\GetPlatformFeePreviewHandler;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class GetPlatformFeePreviewAction extends BaseAction
{
public function __construct(
private readonly GetPlatformFeePreviewHandler $handler,
)
{
}
public function __invoke(Request $request, int $eventId): JsonResponse
{
$this->isActionAuthorized($eventId, EventDomainObject::class);
$this->validate($request, [
'price' => 'required|numeric|min:0',
]);
$dto = new GetPlatformFeePreviewDTO(
eventId: $eventId,
price: (float)$request->input('price'),
);
$result = $this->handler->handle($dto);
return $this->resourceResponse(PlatformFeePreviewResource::class, $result);
}
}