Laravel验证有错误:类翻译器不存在

时间:2017-09-19 07:45:41

标签: laravel

当我使用我的php UserController添加此代码时出错,如果删除它,那么它有效!

public function signUp(Request $request){
    $this->validate($request,[
        'name' => 'required|string|max:255',
        'email' => 'required|string|email|max:255',
        'password' => 'required|string|min:6',
        //'password_confirmation' => 'required|string|min:6|same:password',
    ]);
}

UserController

enter image description here

3 个答案:

答案 0 :(得分:1)

将您的确认密码字段重命名为password_confirmationdocs建议

  

验证中的字段必须具有foo_confirmation的匹配字段。例如,如果验证字段为password,输入中必须存在匹配的password_confirmation字段

并按照以下方式进行验证:

$this->validate($request,[
        'name' => 'required|string|max:255',
        'email' => 'required|string|email|max:255',
        'password' => 'required|string|min:6|confirmed',
        'password_confirmation' => 'required|string|min:6'
    ]);

答案 1 :(得分:0)

试试这个 'password_confirmation'=> '所需|分钟:6 |最大:255 |相同的:密码',

答案 2 :(得分:0)

试试此代码

$this->validate($request,[
    'name' => 'required|string|max:255',
    'email' => 'required|string|email|max:255',
    'password' => 'required|string|min:6|same:password_confirmation'
]);