当我在CustomRequest类中扩展dingoapi FormRequest类时,对于"消息"字段我收到此默认消息。
{
"message": "422 Unprocessable Entity",
"errors": {
"email": [
"The email has already been taken."
]
},
"status_code": 422
}
如何覆盖此消息字段?
答案 0 :(得分:3)
在Form Request
课程中,您可以覆盖名为messages
的方法,并根据每条规则将信息放在那里:
public function messages() {
return [
'name.required' => 'Please, provide me with your name',
'email.required' => 'Email address is mandatory',
'email.unique' => 'This email is already in our database'
]
);
}