34 lines
873 B
PHP
34 lines
873 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\District;
|
|
use App\Models\Regency;
|
|
use App\Models\Village;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
class RegionController extends Controller
|
|
{
|
|
public function regencies(string $provinceId): JsonResponse
|
|
{
|
|
return response()->json(
|
|
Regency::where('province_id', $provinceId)->orderBy('name')->get(['id', 'name'])
|
|
);
|
|
}
|
|
|
|
public function districts(string $regencyId): JsonResponse
|
|
{
|
|
return response()->json(
|
|
District::where('regency_id', $regencyId)->orderBy('name')->get(['id', 'name'])
|
|
);
|
|
}
|
|
|
|
public function villages(string $districtId): JsonResponse
|
|
{
|
|
return response()->json(
|
|
Village::where('district_id', $districtId)->orderBy('name')->get(['id', 'name'])
|
|
);
|
|
}
|
|
}
|