编写以下路由的最佳和正确方法是什么:
Route::group(['middleware' => ['web']],function (){
Route::prefix('user')->group(function () {
//this address shows the login page
Route::any('login', 'User@login_page');
//others address that control the login action
Route::prefix('login')->group(function (){
Route::get('google', 'User@check_user_login_with_google');
Route::post('form', 'User@check_user_login_with_form');
Route::get('google-url', 'User@redirect_to_google_url');
});
//these address control the registration actions
Route::any('register','User@register');
Route::any('register/check','User@check_user_registration');
});
});
答案 0 :(得分:2)
您可以一次性完成所有操作:
Route::group(['prefix' => 'user', 'as' => 'user.', 'middleware' => ['web']], function() {
Route::any('login', 'User@login_page');
...
})
答案 1 :(得分:1)
您可以在单独的关联数组中使用所有这些,并将此数组分配给组,这里是如何做到的。
Route::group(['prefix' => 'user', 'as' => 'user.', 'middleware' => ['web']], function() {
Route::any('login', 'User@login_page');
...
})
希望这可以帮到你