If there a way to check whether or not the validator failed specifically because of the unique
rule?
$rules = array(
\'email_address\' =
Check for a specific rule within the returned array of failed rules
if ($validator->fails()) {
$failedRules = $validator->failed();
if(isset($failedRules['email_address']['Unique'])) {
...
This will display an error and tell you what failed:
Controller
if($validation->fails()){
return Redirect::back()->withErrors($validation)->withInput();
}
foreach($errors->all() as $error) {
echo $error;
}
And in your blade template add this:
@foreach($errors->all() as $error)
<div>
{{$error}}
</div>
@endforeach
And that will return a message with whatever the error is. Email doesn't match. Field is required. Blah blah
You can also remove that email array from the $message. The validator will handle all that for you. You only want to use that if you want custom messages.
You can also try to var_dump this statement:
var_dump($validation->errors()); die;