0
votes

I keep having this error every time I try to validate a form:

Undefined variable: errors (View: /home/vagrant/Code/talents/resources/views/welcome.blade.php)

I tried modifying the kernel.php file, and also adding the route into the 'middleware' => 'web' in the routes file, but none of those seem to fix the problem.

Undefined variable: errors in Laravel

2
Do you have cached routes in bootstrap/routes.php ?Marcin Nabiałek
Show us the relevant files such as kerel.php!Untitled123
it is all working, in regards to the errors. the problem is the redirect function. It is not passing to the view.Edgar Velazquez

2 Answers

0
votes

If you need access to session errors you need sessions. You should move your '/' route to the 'web' middleware group.

Route::group(['middleware' => ['web']], function () {
    Route::get('/', function () {
        return view('welcome');
    });        
});

The 'web' middleware group gives you sessions and the session errors.

If you have this setup at the moment and are still having that issue, you may want to change any adjustments you made to Kernel.php and use the default one. If you change the middleware applied to the 'web' group, you could cause an issue where things dont get applied correctly.

In regard to the session errors, those are being shared with views in \Illuminate\View\Middleware\ShareErrorsFromSession, which the 'web' middleware group has applied.

0
votes

Solved

You may change any one of the following:

1. put your working route (app/http/routes.php) on

Route::group(['middleware' => ['web']], function () { // Here like Route::get('/', 'TodoController@index'); Route::post('/', 'TodoController@store'); });

See the image here

2. Move your protected $middlewareGroups web (app/Http/Kernel.php) on protected $middleware = []

See the image here