嗨,有人可以帮我解决这个问题:
'max' => [
'file' => 'The :attribute may not be greater than :max kilobytes.',
],
我的信息是:
The image may not be greater than 2048 kilobytes.
我需要它像这样:
The question image may not be greater than 2 mb.
有办法做到这一点..?请帮忙..!
答案 0 :(得分:0)
我认为覆盖错误消息的最简单方法是使用messages()
类的FormRequest
方法。
class UploadFileRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'image' => "file|max:2048",
];
}
/**
* Get custom messages for validator errors.
*
* @return array
*/
public function messages()
{
return [
'image.max' => "The question image may not be greater than 2 mb.",
];
}
}