简体   繁体   中英

Laravel 5.2 login message custom

I am kind of new to Laravel framework, working on 5.2. I run

php artisan make:auth()

Now I am trying to custom the error message on the login form "these credentials do not match our records"

I tried to override the failLoginMessage() method in AuthController.php but it's not working. One more thing the password field error message is not working at all even though I enter the right email but wrong password the validation runs on email field but not on password field.

As I can't see your code, check this out: https://github.com/laravel/laravel/blob/5.2/resources/lang/en/auth.php , this is on branch 5.2 in Github, that is the lang file, you can define a new folder inside of lang directory named es and make inside it an auth.php , if you feel good and warm in terminal cd <your_proy_dir> && mkdir -p resources/lang/es/ && touch resources/lang/es/auth.php , and define a fundamentals key inside that file:

'failed' => 'Estos credenciales no coinciden con ninguno almacenado.',

That would be for spanish, but is the same principle for every language, then, to change your application language, you just have to go to the config/app.php and change this:

 'locale' => 'en',

for this:

 'locale' => 'es',

Once again, this is for spanish, but is the same principle.

Good luck. Cheers! ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM