ErrorBag is always empty in Laravel 5.2

后端 未结 3 1940
天涯浪人
天涯浪人 2020-11-30 15:38

I was creating a new Laravel project and when debugging the errors of a form request, I noticed that my ErrorBag was always empty. Even when in the controller $validat

相关标签:
3条回答
  • 2020-11-30 16:15

    Are you triggering any form validation errors? If you are then try this -

    $messages = $validator->errors();
    

    The messages variable should now have your errors

    If you error bag is still empty

    • Check if your post data are being posted to the proper route/controller
    0 讨论(0)
  • 2020-11-30 16:29

    In my case, I moved \Illuminate\Session\Middleware\StartSession::class from my web group to the $middleware array.

    0 讨论(0)
  • 2020-11-30 16:30

    As of v5.2.27, released on 2015-03-25, all routes in app\Http\routes.php are now in the web middleware group by default. If you have explicitly specified this middleware group inside your app\Http\routes.php file, you should remove it and that should resolve your issue.

    0 讨论(0)
提交回复
热议问题