Initial commit
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?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'])
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user