jiyis jiyis - 6 months ago 52
PHP Question

Multi auth for laravel 5.2 use middleware

I want to use multi authenticate in

Laravel 5.2
. But I found a strange problem.

Here is my code in
route.php
.

However I can not get
$errors
in the
login.blade.php
, it just return null.

<?php
Route::group(['middleware' => ['web'], 'namespace' => 'Admin', 'prefix' => 'admin'], function () {
Route::auth();
});
?>


But when I remove the web middleware, it works.

<?php
Route::group(`enter code here`['namespace' => 'Admin', 'prefix' => 'admin'], function () {
Route::auth();
});
?>


I don't know why. My understanding is that when I want to use the session, I must use the web middleware.

Can somebody help me?I would appreciate you. Thank you.

Answer

Because on Laravel 5.2 the web middleware is automatically applied, your routes in routes.php are grouped with prefix App\Http\Controllers and web middleware. You can find this definition on mapWebRoutes() method of the RouteServiceProdiver.php.

Comments