I have a controller that validates some input and when validation fails it passes the errors to my view:
public function updateAccount(){
$user = Auth::user();
$validation = User::validateAccount(Input::all());
if( $validation->passes() ){
$user->fill(Input::all());
$user->save();
return Redirect::back();
} else {
return Redirect::back()
->withErrors($validation)
->withInput();
}
}
The code for User::validateAccount(); looks like this:
public static function validateAccount($input){
$rules = [
'website' => 'url'
];
$validation = Validator::make($input, $rules);
return $validation;
}
In my view I display the errors like this:
@if($errors->any())
<div class="errors">
<ul>
@foreach($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
However, instead of the default, user friendly error output I get this. For a URL validation error it displays:
validation.url
How do I get Laravel to display the default, user friendly error messages that are configured in app/lang/en/validation.php?
So for a URL error this should be:
"The :attribute format is invalid."