<?php

namespace App\Http\Controllers\Api\V1\Admin\Config;

use App\Support\ApiResponse;
use App\Models\RiskCapVersion;
use Illuminate\Http\JsonResponse;
use App\Http\Controllers\Controller;
use App\Support\AdminConfigPresenter;

/** GET /api/v1/admin/config/risk-cap-versions/{id} */
final class RiskCapVersionShowController extends Controller
{
    public function __invoke(int $id): JsonResponse
    {
        /** @var RiskCapVersion $v */
        $v = RiskCapVersion::query()->with('items')->whereKey($id)->firstOrFail();

        return ApiResponse::success(AdminConfigPresenter::riskCapVersionDetail($v));
    }
}
