通常验证消息与我的 json 响应类似
"error_details": {
"email": [
"The email field is required."
],
"password": [
"The password field is required."
]
}
但我想做
"error_details": {
"password": "The password field is required.",
"email": "The email field is required."
}
最佳答案
您可以使用array_flatten()
帮助器:
array_flatten($validator->getMessageBag()->getMessages());
这将返回所有验证器错误的一维数组。
了解有关 Laravel 助手的更多信息:http://laravel.com/docs/5.0/helpers
关于php - 修改 Laravel 验证消息响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30007131/