lundi 28 mars 2016

Specify Laravel validation language

is it at all possible to tell the Laravel validator which language to use for validation?

I have an application which has its text in English, but for some of the forms, I need the validation errors for the fields to be returned in a different language.

I researched a little and found out that I can just use \App::setLocale('ro') to set the language of the app and thus the file under resources/lang/ro/validation.php will be used for the validation, but I do not want to temper with the setLocale. I could, in the worst scenario, temper with it and change the language before the validation and change it back after the validation again, but it doesn't seem like a good solution.

I am looking for something more like this:

$this->validate($request, [
    'title' => 'required',
    'short' => 'required',
], 'lang_that_I_set_in_DB');



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire