I cannot get to work the middleware in the new created module.
This is my route file:
Route::group(['middleware' => ['auth']], function()
{
Route::get('/dashboard/users', 'Modules\User\Http\Controllers\UserController@index')->name('dashboardUsers');
Route::get('/dashboard/user/{id}/edit', 'Modules\User\Http\Controllers\UserController@edit')->name('dashboardEditUserView');
Route::post('/dashboard/user/{id}/edit', 'Modules\User\Http\Controllers\UserController@update')->name('dashboardEditUserView');
});
Is there something I need to do to be able to use the middleware in the module?
I had to also include the "web" guard before the auth guard in order to work:
Route::group(['middleware' => ['web','auth']], function() { Route::get('/dashboard/users', 'Modules\User\Http\Controllers\UserController@index')->name('dashboardUsers'); Route::get('/dashboard/user/{id}/edit', 'Modules\User\Http\Controllers\UserController@edit')->name('dashboardEditUserView'); Route::post('/dashboard/user/{id}/edit', 'Modules\User\Http\Controllers\UserController@update')->name('dashboardEditUserView'); });
I had to also include the "web" guard before the auth guard in order to work:
Route::group(['middleware' => ['web','auth']], function() { Route::get('/dashboard/users', 'Modules\User\Http\Controllers\UserController@index')->name('dashboardUsers'); Route::get('/dashboard/user/{id}/edit', 'Modules\User\Http\Controllers\UserController@edit')->name('dashboardEditUserView'); Route::post('/dashboard/user/{id}/edit', 'Modules\User\Http\Controllers\UserController@update')->name('dashboardEditUserView'); });
I also encountered exactly the same issue and your answer resolved it too.
Most helpful comment
I had to also include the "web" guard before the auth guard in order to work:
Route::group(['middleware' => ['web','auth']], function() { Route::get('/dashboard/users', 'Modules\User\Http\Controllers\UserController@index')->name('dashboardUsers'); Route::get('/dashboard/user/{id}/edit', 'Modules\User\Http\Controllers\UserController@edit')->name('dashboardEditUserView'); Route::post('/dashboard/user/{id}/edit', 'Modules\User\Http\Controllers\UserController@update')->name('dashboardEditUserView'); });