Ad

Not Fixable Undefined Variable Errors Laravel 5.2

- 1 answer

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

Ad

Answer

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.

Ad
source: stackoverflow.com
Ad