Laravel 5.2不显示注册错误 [英] Laravel 5.2 Does not show errors in register

查看:71
本文介绍了Laravel 5.2不显示注册错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在web middleware中添加了我的路线. 当我在寄存器中发布null值时,它没有显示验证错误. 但是,当我从路线中删除web middleware时,它可以正常工作.

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();
}

它不起作用,但是

Route::auth();

正常工作

Kernel.php

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,

    ],

推荐答案

您应该在中间使用它(如果您要在中间使用它)-

U should use this in your middle-were (if u are trying to use it in middle-were)-

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

为我工作.

如果您想这样做,那么您可以尝试此操作-

If u want to do that in view, then u can try this-

route('my_route_name');

URL::to('foo');

或者,

url('foo');

url('foo');

如果您想在 route.php 中使用,则在此处给出示例-

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

更多内容可以在-

  1. https://laravel.com/docs/master/routing#named路线

https://laravel.com/docs/master/middleware#defining -中间件

这篇关于Laravel 5.2不显示注册错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆