Try replacing Input:all with $request->all() since you are passing the $request in anyway
Mar 11, 2016
6
Level 2
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.
Please or to participate in this conversation.