1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
namespace App\Http\Controllers;
use App\District;
use Illuminate\Http\Request;
class DistrictController extends Controller
{
public function provinces()
{
$provinces = District::groupBy('province_code')
->get();
return response()->json($provinces);
}
public function amphoes($province_code)
{
$amphoes = District::where('province_code',$province_code)
->groupBy('amphoe_code')
->get();
return response()->json($amphoes);
}
public function districts($province_code,$amphoe_code)
{
$districts = District::where('province_code',$province_code)
->where('amphoe_code',$amphoe_code)
->groupBy('district_code')
->get();
return response()->json($districts);
}
public function detail($province_code,$amphoe_code,$district_code)
{
$districts = District::where('province_code',$province_code)
->where('amphoe_code',$amphoe_code)
->where('district_code',$district_code)
->get();
return response()->json($districts);
}
}