<?php Route::group(['prefix' => 'ajax'], function () { # SelectBox Nations Route::post('sbNations', function () { $results = Nation::all(); $code = ''; foreach ($results as $result) { $code .= '<option value="' . $result->id . '">' . $result->libelle . '</option>'; } return $code; }); # SelectBox Regions Route::post('sbRegions/{nation_id}', function ($nation_id) { $results = Region::where('nation_id', '=', $nation_id)->get(); $code = ''; foreach ($results as $result) { $code .= '<option value="' . $result->id . '">' . $result->libelle . '</option>'; } return $code; }); # SelectBox Clubs Route::post('sbClubs/{region_id}', function ($region_id) { $results = Club::where('region_id', '=', $region_id)->get(); $code = ''; foreach ($results as $result) { $code .= '<option value="' . $result->id . '">' . $result->nom . '</option>'; } return $code; }); # LoadPage
# List Route::get('/list', ['as' => 'test.list', 'uses' => 'TestsController@liste']); # Home Route::get('/home', ['as' => 'test.home', 'uses' => 'TestsController@home']); # ScoreCard Angular Route::get('/scorecard', ['as' => 'test.scorecard', 'uses' => 'TestsController@scorecard']); # Divers test Route::get('/divers', ['as' => 'test.divers', 'uses' => 'TestsController@divers']); # Show Session Route::get('/showSession', ['as' => 'test.showSession', 'uses' => 'TestsController@showSession']); # Show Ajax Route::get('/showAjax', ['as' => 'test.showAjax', 'uses' => 'TestsController@showAjax']); # Test Ajax Route::get('/getAjax/{model}/{id?}', function ($model, $id = 0) { if ($id == 0) { return $model::all(); } return $model::find($id); }); Route::get('/getNation', function () { return Nation::all(); }); Route::get('/getRegion/{nation_id}', function ($nation_id) { $result = DB::table('regions')->select('regions.id', 'regions.libelle', 'nation_id')->join('nations', 'regions.nation_id', '=', 'nations.id')->where('regions.nation_id', '=', $nation_id)->get(); return $result; }); Route::get('/getClub/{region_id}', function ($region_id) { $result = DB::table('clubs')->select('clubs.id', 'clubs.nom', 'region_id', 'regions.libelle')->join('regions', 'clubs.region_id', '=', 'regions.id')->where('clubs.region_id', '=', $region_id)->get(); return $result; }); });