John1984 John1984 - 1 year ago 107
PHP Question

Laravel's withInput() and withErrors() are empty

I have a laravel form which submits data via a POST request to a controller like so...

public function store()
$result = Validator::make(request() -> all(), $this -> rules);

if ($result -> fails())
return back() -> withInput() -> withErrors($result);

However, when I'm redirected back, accessing input data via the 'old' helper method returns nothing, as does reading data from $errors.

I believe the session data is being lost (possibly due to a secondary redirect?).

I've checked my routes file in artisan and the web middleware is only being run once on the routes. I'm also using the database session driver.

Any ideas? I'm using Laravel 5.2.39

Answer Source

Lately i encounter this error and i found the solution... Instead of putting your routes inside of this

Route::group(['middleware' => ['web']], function () { });

Just remove it and it will work properly. Its like 'web' middleware is loading twice.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download