method not exist:app\admin\model\UserModel->validate

Posted on 2022-07-04 18:55  君子不卿  阅读(490)  评论(0编辑  收藏  举报

1.

 

删除model里面没有的validate

添加验证

$validate = new UserValidate();
//            var_dump($validate->check($param));exit;

            if (!$validate->check($param)) {
                return ['code' => 0, 'data' => '', 'msg' => $validate->getError()];
//                return  $validate->getError();
            }
$result =  $this->allowField(true)->save($param);

使用原定义的验证规则

protected $rule =   [
    'toolbar'  => 'unique:admin,username',
];

protected $message  =   [
    'toolbar' => '工号已经存在',
];

 

Copyright © 2024 君子不卿
Powered by .NET 9.0 on Kubernetes

//评论