Laravel language on authentication verification error

I would like to use the default laravel function to show an error, but in a different language. I don't need a "nice name", but it's a translation for the value **: attribute in lang files. Right now if I just use:

<input type="text" placeholder="{{ trans('generic.phone') }}" name="phone" value="{{ old('phone') }}"> @if ($errors->has('phone')) <span class="help-block"> <strong>{{ $errors->first('phone') }}</strong> </span> @endif 

It works fine, because : the attribute occupies the phone field, and in the verification language I:

 'required' => 'The :attribute field is required.', 

But how to manage the phone field with a language file?

Should I write a custom error for each field? Please say no.

The following function is just a wrong example so that you can understand what I'm trying to do

 @if ($errors->has('phone')) <strong>{{ $errors->first(trans('generic.phone')) }}</strong> @endif 
0
php validation laravel
Jan 27 '17 at 15:20
source share
1 answer

Really easy! Just add attributes to the language file! In my case for lang/it/validation.php

I just installed:

 'attributes' => [ 'phone' => 'telefono', ], 

while everyone will remain unchanged for offers

 'required' => 'Il campo :attribute &grave; obbligatorio.', 
+1
Jan 27 '17 at 22:25
source share



All Articles