У меня есть объект данных Json, как показано ниже
{
"name": "something",
"location": {
"city": "some where",
"country": "some where",
}
}
Правило, используемое для проверки запроса:
[
'name' => 'required',
'location.city' => 'required',
'location.country' => 'required'
]
, которое возвращает сообщение об ошибке типа
{
"name": [
"The name field is required."
],
"location.city": [
"The location.city field is required."
],
"location.county": [
"The location.country field is required."
]
}
Как мне отформатировать сообщение об ошибке в виде вложенного массива, такого как Запрос.
{
"name": [
"The name field is required."
],
"location": {
"city": [
"The city field is required"
],
"country": [
"The country field is required"
]
}
}
Доступны ли методы по умолчанию?Я использую Illuminate\Foundation\Http\FormRequest