Laravel language on Auth validation error

I would like to use the laravel default functionality to show the error, but in another language.
I don’t need a “nice name”, but a translation for the **:attribute value in lang files.
Right now if I just use:

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

it works perfectly, because the :attribute takes the field phone, and in the validation language I have:
'required' => 'The :attribute field is required.',

But how to manage phone field with a language file?

Do I must have to write a custom error for each field? Please tell me I don’t.

The following function is just a wrong example to let you understand what
I’m trying to do

@if ($errors->has('phone'))
    <strong>{{ $errors->first(trans('')) }}</strong>


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Really simple!
Just add attributes in the language file!
In my case, for lang/it/validation.php

I just set:

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

while all remain the same for the sentences
'required' => 'Il campo :attribute &grave; obbligatorio.',

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x