Laravel5.1 jsValidation 唯一规则问题

Laravel5.1 jsValidation Unique rule issue

我正在使用 laravel-jsValidation,https://github.com/proengsoft/laravel-jsvalidation,除 Unique 规则外一切正常! 这是我所拥有的: 规则:

protected $userValidate=[
          'lastname' => 'required|max:100|min:2',
          'firstname' => 'max:100|min:2',
          'username' => 'required|unique:users|min:2',
          'email' => 'required|unique:users|email|max:255',
          'password' => 'required|confirmed|min:6',  ];

获取用户列表功能:

public function getUsers(){
  $validator = JsValidator::make($this->userValidate);      
  return view('admin.usersList')->withValidator($validator);}

商店功能:

public function store(Request $request){   
  $data = $request->all();

  $v = Validator::make($data, $this->userValidate);           

  if ($v->fails())
  {
      return redirect()->back()->withErrors($v->errors());          
  }  

  $user = User::create([
        'lastname' => $data['lastname'],
        'firstname' => $data['firstname'],
        'username' => $data['username'],
        'email' => $data['email'],                        
        'password' => bcrypt($data['password']), 
        'confirmed' => 1,                 
    ]);       

  return redirect('admin/usersList');}

问题是当我输入用户名或电子邮件时,在其输入的表单下出现一条错误消息:

Whoops, looks like something went wrong.

注意:我设置:'disable_remote_validation' => false, 当我将其更改为 true 时,只有当我输入用户 table !

中不存在的用户名和电子邮件时,它才能正常工作

我的代码有什么错误?

唯一验证需要 table 名称后的列名称。我假设您的列名在数据库中是 email。您的电子邮件规则应如下所示:

'email' => 'required|unique:users,email|email|max:255',

我认为问题是:这个包不支持远程验证,正如我在 Config/jsValidation.php 中看到的那样:

/* * Enable or disable Ajax validations of Database and custom rules. * By default Unique, ActiveURL, Exists and custom validations are validated via AJAX */ 'disable_remote_validation' => false,

那么如何通过 AJAX 验证此规则?请问有教程吗?

我是 laravel-jsvalidation 包的维护者。此问题已在 1.3.0 版

中修复

规则 UniqueA​​ctiveURLExists 和自定义验证会自动验证。启用它

 'disable_remote_validation' => false,
return [
            'name' => 'required',
            'email' => 'required|email|unique:`admin_users`,email',
            'phone' => 'required|unique:admin_users,phone',
            'password' => 'required|min:6|max:16'
        ];