Route::get("/province", function () { return \App\Models\Thailand\Province::all(); }); Route::get("/province/{provinceId}/amphur", function ($provinceId) { return \App\Models\Thailand\Amphur::where("PROVINCE_ID", "=", $provinceId)->get(); }); Route::get("/province/{provinceId}/amphur/{amphurId}/district", function ($provinceId, $amphurId) { return \App\Models\Thailand\District::where("PROVINCE_ID", "=", $provinceId)->where("AMPHUR_ID", "=", "{$amphurId}")->get(); }); }); Route::group(['middleware' => ['web']], function () { Route::get('/', "FrontendController@index"); Route::get('/post/{id}', "FrontendController@getPost"); }); Route::get('/amphur/{id}/{name}', function ($id, $name) { $amphur = \App\Models\Thailand\Amphur::find($id); $query = Project::query(); $query->where('amphur_id', '=', $id); $projects = $query->get(); return view('frontends.amphur')->with('projects', $projects)->with('amphur', $amphur); }); Route::group(['prefix' => 'project', 'middleware' => ['web']], function () { //project Route::get('/', function (\Symfony\Component\HttpFoundation\Request $request) { $faculty_id = $request->get('faculty_id'); $keyword = $request->get('keyword'); $year = $request->get('year'); $query = Project::query(); if ($faculty_id) { $query = $query->where('faculty_id', '=', $faculty_id); }