假设我有以下代码:
Route::group(['domain' => '{tenant_domain}.myapp.com', 'middleware' => 'tenant'], function () {
Route::get('/', function () {
// send to dashboard/login based on auth
if (Auth::check()) {
return redirect()->route('dashboard');
} else {
return redirect()->route('login');
}
});
Route::group(['middleware' => 'guest'], function () {
// login routes
Route::get('login', 'Auth\LoginController@showLoginForm')->name('login');
Route::post('login', 'Auth\LoginController@login');
// password reset routes
Route::get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
Route::post('password/reset', 'Auth\ResetPasswordController@reset');
});
});
现在,tenant
中间件使用tenant_domain
。但是,我想这样做,以便所有子路由都不需要tenant_domain
作为其控制器中的参数。
我该怎么做?