Last active
August 11, 2020 13:14
-
-
Save pradeeprjth/541d6da2e11d1310ff129d2d709b2ed5 to your computer and use it in GitHub Desktop.
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; | |
use DB; | |
class DropdownController extends Controller | |
{ | |
public function index() | |
{ | |
$countries = DB::table("countries")->pluck("name","id"); | |
return view('index',compact('countries')); | |
} | |
public function getStateList(Request $request) | |
{ | |
$states = DB::table("states") | |
->where("country_id",$request->country_id) | |
->pluck("name","id"); | |
return response()->json($states); | |
} | |
public function getCityList(Request $request) | |
{ | |
$cities = DB::table("cities") | |
->where("state_id",$request->state_id) | |
->pluck("name","id"); | |
return response()->json($cities); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment