Hi, I want to use request name ('/') when the user is authorized and for the guests. I want to use localhost/ to route user to admin panel when he is authorized, and when he is guest I want to route him to localhost/ too (in this case will be home page for all users). So, I tried to use it into my routes.php:
Route::group(['middleware' => 'guest'], function()
{
Route::get('/', ['as' => 'auth.login', 'uses' => 'Auth\AuthController@formLogin']);
Route::post('login', ['as' => 'auth.login.post', 'uses' => 'Auth\AuthController@login']);
});
Route::group(['middleware' => 'auth'], function()
{
Route::get('/', function() {
view('welcome');
});
Route::get('logout', ['as' => 'auth.logout', 'uses' => 'Auth\AuthController@logout']);
});
But when I make the command php artisan route:list I see that:
+--------+----------+--------+-----------------+-------------------
| Method | URI | Name | Middleware |
+--------+----------+--------+-----------------+---------------------
|GET|HEAD | / | | auth |
|POST | login | auth.login.post | guest,guest |
|GET|HEAD | logout | auth.logout | auth,guest |
+--------+----------+--------+-----------------+---------------------
middleware 'auth' overrides middleware 'guest' for the '/' request. This is a very big problem for me.
In Laravel 4.2 this could be done through the filters 'before' => 'guest' and 'before' => 'auth'.
How can I filter the same requests ('/') throw middleware? Thanks in advance for any help!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community