Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Baadier's avatar

Laravel validation always passes and nothing returned to the session

My validation always passed no matter what I put through the form. Nothing gets added to the session either.

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Input;

use App\Http\Requests;

class EmailFinderController extends Controller
{
    public function findEmails(Request $request){
        $rules = array(
            'name'               => 'required',
            'surname'            => 'required',
            'web'                => 'required|url'
        );

        $validator = Validator::make(Input::all(), $rules);

//        dd($validator);

        if ($validator->fails()) {

            return Redirect::back()
                ->withErrors($validator)
                ->withInput(Input::all());

        } else {
    // The rest of this has been commented out.
            return Redirect::back()->with('success','Thanks for your submission, we will be in touch shortly.');

        }
    }
}

My dd() shows no failed rules regardless of what I put through.

0 likes
6 replies
N9ne's avatar

Try replacing Input:all with $request->all() since you are passing the $request in anyway

Baadier's avatar

So I had my dd() in the wrong place. The validation is only evaluated when I run:

$validator->fails()

I can see it fail in the failed rules that is returned with dd() but nothing shows up in the session?

Snapey's avatar

You must use web middleware in all routes.

I don't see how not starting sessions resolves your issue since without a session there can be no session based response. ?

Baadier's avatar

I currently have all routes using the web middleware.

It makes no sense as to why its working but it is?

Any ideas?

Please or to participate in this conversation.