基本上我要做的是自动更改de前缀,所以我只有一个视图。链接可能看起来像这样。
{{URL::to('california/search')}}
{{URL::to('florida/search')}}
{{URL::to('arkansas/search')}}
我使用Laravel 5.2
这是我使用的控制器:
//Controllers for states
Route::group(array('prefix' => 'california', "namespace" => 'Test' ), function() {
Route::get("/all", "CalifornaPositionController@all");
Route::get('/search',['uses' => 'CalifornaPositionController@getSearch','as' => 'search']);
Route::get('/show/{id}', 'CalifornaPositionController@show');
});
Route::group(array('prefix' => 'florida', "namespace" => 'Test' ), function() {
Route::get("/all", "FloridadPositionController@all");
Route::get('/search',['uses' => 'FloridadPositionController@getSearch','as' => 'search']);
Route::get('/show/{id}', 'FloridadPositionController@show');
});
Route::group(array('prefix' => 'arkansas', "namespace" => 'Test' ), function() {
Route::get("/all", "ArkansasPositionController@all");
Route::get('/search',['uses' => 'ArkansasPositionController@getSearch','as' => 'search']);
Route::get('/show/{id}', 'ArkansasPositionController@show');
});