我的route.php文件中有多个Route::group
,我无法访问另一个Route::group
内的中间件。
以下是一个示例代码段
Route::group(['middleware' => ['web']], function () {
//Login Routes...
Route::get('/admin', 'AdminAuth\AuthController@showLoginForm');
Route::get('/admin/login', 'AdminAuth\AuthController@showLoginForm');
//Route::post('/admin/login', 'AdminAuth\AuthController@login');
//Route::get('/admin/logout', 'AdminAuth\AuthController@logout');
// Registration Routes...
Route::get('admin/register', 'AdminAuth\AuthController@showRegistrationForm');
Route::post('admin/register', 'AdminAuth\AuthController@register');
Route::group([['middleware' => ['admin']], 'prefix' => 'admin'], function () {
Route::get('/admin', array('uses' => 'AdminController@index'));
Route::get('/departments', array('as' => '_departments', 'uses' => 'DepartmentController@index'));
Route::get('/department/add', array('as' => '_department_add', 'uses' => 'DepartmentController@add'));
Route::post('/department/add', array('as' => 'add', 'uses' => 'DepartmentController@add'));
});
});
从上面代码Admin
无法访问中间件,但如果我将Admin
中间件置于最顶层Route::group
,则可以使用。
现在,我使用管理中间件内部Route::group
,因为外部路由组不需要检查身份验证