tp5 唯一性验证 踩坑

validate/Admin.php

 'require|min:3|unique:admin',
        'password'   => 'require|min:6',    
    ];
    
    protected $message  =   [
        'username.require' => '用户名必须',
        'username.min'     => '用户名不少于3个字符长度',
        'username.unique'     => '用户名唯一',
        'password.require'   => '用户密码必须',
        'password.min'  => '密码长度必须大于6',
    ];
    
    protected $scene = [
        'add'  =>  ['username','password'],
        'edit' =>  ['username'=>'require|min:3','password'=>'min:6'],
    ];
}

unique后边必须跟上 :表名

你可能感兴趣的:(tp5 唯一性验证 踩坑)