Created
September 2, 2021 07:36
-
-
Save syofyanzuhad/665daf2f2a3fc654afc991968bd55e74 to your computer and use it in GitHub Desktop.
Its used for laravolt/indonesia package
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use Illuminate\Http\Request; | |
class DependentDropdownController extends Controller | |
{ | |
public function provinces() | |
{ | |
return \Indonesia::allProvinces(); | |
} | |
public function cities(Request $request) | |
{ | |
return \Indonesia::findProvince($request->id, ['cities'])->cities->pluck('name', 'id'); | |
} | |
public function districts(Request $request) | |
{ | |
return \Indonesia::findCity($request->id, ['districts'])->districts->pluck('name', 'id'); | |
} | |
public function villages(Request $request) | |
{ | |
return \Indonesia::findDistrict($request->id, ['villages'])->villages->pluck('name', 'id'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment