<?php

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

use App\Http\Controllers\Controller;
use App\Models\System\Settings\Location\Province;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class ProvinceController extends Controller
{
    /**
     * Get provinces
     */
    public function index(Request $request): JsonResponse
    {
        return response()->rest(
            Province::query()
                ->get()
                ->map(fn ($province) => [
                    'id' => $province->id,
                    'region' => $province->region,
                    'name' => $province->name,
                ]));
    }
}
