Exemple #1
0
    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);
        }
            <div class="menu">
                <?php 
$faculties = \App\Models\Faculty::all();
?>
                @foreach($faculties as $faculty)
                    <a class="link item" href="/project?faculty_id={{$faculty->id}}">{{$faculty->name_th}}</a>
                @endforeach

            </div>
        </div>
        <div class="ui simple dropdown item">
            พื้นที่เป้าหมาย
            <i class="dropdown icon"></i>
            <div class="menu">
                <?php 
$amphurs = \App\Models\Thailand\Amphur::where("province_id", "=", "44")->get();
?>
                @foreach($amphurs as $amphur)
                    <a class="link item" href="/amphur/{{$amphur->AMPHUR_ID}}/{{$amphur->AMPHUR_NAME}}">{{$amphur->AMPHUR_NAME}}</a>
                @endforeach
            </div>
        </div>
        <div class="ui simple dropdown item">
            ปีที่ดำเนินโครงการ
            <i class="dropdown icon"></i>
            <div class="menu">
                <?php 
$years = \App\Models\Year::orderBy('year', 'desc')->get();
?>
                @foreach($years as $year)
                    <a class="link item" href="/project?year={{$year->year}}">{{$year->year}}</a>