Laravel: 一个字段中相同规则的验证消息

Laravel: validation message for same rules in one field

我是 Laravel 的新手,我尝试验证请求。我必须满足以下要求 class:

namespace App\Http\Requests;

class TestRequest extends FormRequest
{
    protected function rules() 
    { 
        return [
            'group_id' => 'required|exists:groups,id,deleted_at,NULL|exists:group_users,group_id,user_id,' . \Auth::user()->id
        ];
    }
}

我的问题是:

我的问题是:

PS:我正在使用 Laravel 5.3

我建议编写自定义规则。检查下面的 link 以了解将其添加到代码中的位置

https://laravel.com/docs/5.3/validation#custom-validation-rules

Validator::extend('group_check', function($attribute, $value, $parameters, $validator) {
    // Do custom exists check 1;
    $group = Group::where('id', $value)->where('deleted_at', 'null')->first();

    if (!$group) {
        return false;
    }

    // Do custom exists check 2;
});

Validator::replacer('group_check', function($message, $value, $parameters, $validator) {
    // Do custom exists check 1 but instead of returning false, return a custom message

    // Do custom exists check 2 return a custom message
});