<?php

namespace App\Http\Controllers\API;

use App\Http\Controllers\Controller;
use App\Http\Resources\CategoryResource;
use App\Models\Kategori;
use Illuminate\Http\JsonResponse;

class KategoriController extends Controller
{
    public function index(): JsonResponse
    {
        $kategoris = Kategori::query()
            ->withCount('wisatas')
            ->orderBy('nama')
            ->get();

        return response()->json([
            'success' => true,
            'message' => 'Success',
            'data' => CategoryResource::collection($kategoris),
        ]);
    }
}
