Ingen beskrivning
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AdminUser.php 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Yzncms [ 御宅男工作室 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2018 http://yzncms.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 御宅男 <530765310@qq.com>
  10. // +----------------------------------------------------------------------
  11. // +----------------------------------------------------------------------
  12. // | 登录验证
  13. // +----------------------------------------------------------------------
  14. namespace app\admin\validate;
  15. use think\Validate;
  16. class AdminUser extends Validate
  17. {
  18. //定义验证规则
  19. protected $rule = [
  20. 'username|用户名' => 'unique:admin|require|alphaDash|length:3,20',
  21. 'password|密码' => 'require|length:3,20|confirm',
  22. 'email|邮箱' => 'email|unique:admin',
  23. 'mobile|手机' => 'mobile|unique:admin',
  24. 'roleid|权限组' => 'require',
  25. ];
  26. // 登录验证场景定义
  27. public function sceneUpdate()
  28. {
  29. return $this->only(['username', 'password', 'email', 'mobile', 'roleid'])
  30. ->remove('password', 'require');
  31. }
  32. //定义验证场景
  33. protected $scene = [
  34. 'insert' => ['username', 'password', 'email', 'roleid', 'mobile'],
  35. ];
  36. }