Answer the question
In order to leave comments, you need to log in
Is it possible to use the Locale facade in request?
I validate the data from the form using request:
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class ContactRequest extends FormRequest
{
public function rules()
{
return [
'name' => 'required||min:2|max:80|regex:/^[^0-9]+$/',
'service' => 'required',
'email' => 'required|email',
'filename' => 'max:25000',
'phone' => 'required|regex:/^((\s*)?(\+)?)([- _():=+]?\d[- _():=+]?){10,12}(\s*)?$/'
];
}
public function messages(){
return[
'name.required' => "Не заполнено поле \"Имя\"",
'name.min' => "Поле \"Имя\" должно содержать 2 или больше символов",
'name.max' => "Поле \"Имя\" должно содержать не больше 80 символов",
'name.regex' => "Поле \"Имя\" не должно содержать цифр",
'service.required' => "Пожалуйста выберете тип услуги из списка",
'email.required' => "Не заполнено поле \"email\"",
'email.email' => "Указан не корректный email адрес",
'filename.max' => "Максимально допустимый размер файла 25 мегабайт",
'phone.regex' => "Не верный формат номера телефона",
'phone.required' => "Не заполнено поле \"Номер телефона\""
];
}
}
Answer the question
In order to leave comments, you need to log in
Use the same __() function
And for some of the standard validations, there are already texts in lang/en/validation.php
Does localization out of the box not work for validation errors? Everything should be, take a look at the documentation.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question