<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Laravolt\Indonesia\Models\City;
use Laravolt\Indonesia\Models\District;
use Laravolt\Indonesia\Models\Village;

class WilayahController extends Controller
{
    public function getKota(Request $request)
    {
        $kota = City::where('province_code', $request->code)->get();
        return response()->json($kota);
    }

    public function getKecamatan(Request $request)
    {
        $kecamatan = District::where('city_code', $request->code)->get();
        return response()->json($kecamatan);
    }

    public function getDesa(Request $request)
    {
        $desa = Village::where('district_code', $request->code)->get();
        return response()->json($desa);
    }
}