<?php

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

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

/** GET /api/v1/admin/play-types */
final class PlayTypeIndexController extends Controller
{
    public function __invoke(): JsonResponse
    {
        $rows = PlayType::query()->orderBy('sort_order')->orderBy('play_code')->get();

        return ApiResponse::success([
            'items' => $rows->map(fn (PlayType $t) => AdminConfigPresenter::playType($t))->values()->all(),
        ]);
    }
}
