32 lines
860 B
PHP
32 lines
860 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\V1\Admin\Draw;
|
|
|
|
use App\Models\Draw;
|
|
use App\Lottery\ErrorCode;
|
|
use App\Support\ApiResponse;
|
|
use Illuminate\Http\JsonResponse;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Services\Draw\DrawAdminActionService;
|
|
|
|
final class DrawCancelController extends Controller
|
|
{
|
|
public function __construct(
|
|
private readonly DrawAdminActionService $service,
|
|
) {}
|
|
|
|
public function __invoke(Draw $draw): JsonResponse
|
|
{
|
|
try {
|
|
$cancelled = $this->service->cancelBeforeResult($draw);
|
|
} catch (\RuntimeException) {
|
|
return ApiResponse::error(trans('api.client_error'), ErrorCode::ClientHttpError->value, null, 409);
|
|
}
|
|
|
|
return ApiResponse::success([
|
|
'draw_no' => $cancelled->draw_no,
|
|
'status' => $cancelled->status,
|
|
]);
|
|
}
|
|
}
|