Laravel 5.2 required_without_all 请求问题

Laravel 5.2 required_without_all Request Issue

我遇到了 required_without_all 的问题。我有三个元素,至少要填一个。我的文件输入名称是 image[]。添加图像但将 titlebody 留空仍然会导致验证错误,即使它不应该如此。

对我做错了什么有什么想法吗?

public function rules()
{
    return [
        'title'   => 'required_without_all:body,image.*',
        'body'    => 'required_without_all:title,image.*',
        'image.*' => 'required_without_all:body,title',
    ];

}

public function messages()
{
    return [
        'title.required_without_all'    => 'At least one field is required',
        'body.required_without_all'     => 'At least one field is required',
        'image.*.required_without_all'  => 'At least one field is required',
    ];
}

在这里回答:

基本上,将 image 添加为数组并从规则中删除 *

Laravel 5.3 中还有一个错误阻止了类似的工作;看到这个线程:https://github.com/laravel/framework/issues/15044#issuecomment-244364706

public function rules()
{
    return [
        'title'   => 'required_without_all:body,image',
        'body'    => 'required_without_all:title,image',
        'image'   => 'array',
        'image.*' => 'required_without_all:body,title',
    ];
}