Laravel 5.2不显示寄存器错误

时间:2016-03-28 07:15:17

标签: php laravel laravel-5 laravel-5.2 laravel-middleware

我在web middleware添加路线。 当我在寄存器中发布null值时,它不会显示验证错误。 但是,当我从路线中移除web middleware时,它可以正常工作。

Route::group(['middleware' => ['web']], function () {
      Route::auth();
}

它不起作用,但是

Route::auth();

正常工作

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 个答案:

答案 0 :(得分:0)

U应该在你的中间使用它(如果你试图在中间使用它) -

return redirect()->route('auth');

为我工作。

如果你想在视野中这样做,那么你可以尝试这个 -

route('my_route_name');

URL::to('foo');

或者,

URL( '富');

如果你想在 route.php 中使用,那么这里给出一个例子 -

  

https://github.com/abrarjahin/laravel_5.2_form_handeling/blob/master/app/Http/routes.php

更多信息可以在 -

中找到
  1. https://laravel.com/docs/master/routing#named-routes

  2. https://laravel.com/docs/master/middleware#defining-middleware