问题
I add my routes in web middleware
.
When I post null
value in register, it does not show me validation errors.
But when I remove web middleware
from my route it works correctly.
Route::group(['middleware' => ['web']], function () {
Route::auth();
}
it does not work, but
Route::auth();
works correctly
Kernel.php
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\Authenticate::class, ### redirect if Authenticate
\App\Http\Middleware\VerifyCsrfToken::class,
];
/**
* The application's route middleware groups.
*
* @var array
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
// \App\Http\Middleware\VerifyCsrfToken::class,
],
回答1:
U should use this in your middle-were (if u are trying to use it in middle-were)-
return redirect()->route('auth');
Worked for me.
If u want to do that in view, then u can try this-
route('my_route_name');
Or
URL::to('foo');
Or,
url('foo');
If u want to use in route.php then an example is given in here-
https://github.com/abrarjahin/laravel_5.2_form_handeling/blob/master/app/Http/routes.php
More can be found in-
https://laravel.com/docs/master/routing#named-routes
https://laravel.com/docs/master/middleware#defining-middleware
来源:https://stackoverflow.com/questions/36257730/laravel-5-2-does-not-show-errors-in-register