Laravel 5.2 Does not show errors in register

最后都变了- 提交于 2019-12-12 03:09:15

问题


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-

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

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



来源:https://stackoverflow.com/questions/36257730/laravel-5-2-does-not-show-errors-in-register

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!