3
I’m using the Laravel 5.2 Standard Authentication Controller:
php artisan make:auth
As the names are in English, I need to change to Portuguese. I have already set the locale to Portuguese, in /config/app.php:
'locale' => 'pt-BR',
I changed the Authcontroller.php as follows:
protected function validator(array $data)
{
$validator = Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|confirmed|min:6',
]);
$correct_names = [
'name' => 'Nome',
'email' => 'E-mail',
'password' => 'Senha',
];
return $validator->setAttributeNames($correct_names);
}
When creating a user, using http://localhost:8000/Register, the field names are correct, however on the login page, http://localhost:8000/login, the name of the fields continue in English (email and password).
Can someone give a hint how to solve this?
The form described above is identical to the one I have in the question, but works only on the form Register and not on the form login, when, for example, you leave the E-mail and Password field blank and press 'Login', the field name will appear as the original of the system.
– Evert
I know if I change the function validateLogin in the archive Autheticatesusers.php, in Illuminate Foundation Auth and put the way you posted: $this->validate($request, [$this->loginUsername() =>'required','password' => 'required'], ['required' => 'The field :attribute is required! '], [$this->loginUsername() => 'User','password'=> 'Password',]); will work.. but I don’t think this is the best way out by changing the internal code of the Laravel.... =(
– Evert