| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- namespace app\admin\validate;
- class AdminValidate extends BaseValidate
- {
- /**
- * 设置校验规则
- * @var string[]
- */
- protected $rule = [
- 'id' => 'require',
- 'username' => 'require|min:1',
- 'nickname' => 'require|min:1',
- 'password' => 'require|min:6',
- 'phone' => 'nullable|min:11',
- 'email' => 'nullable|email',
- 'sex' => 'require|in:0,1',
- 'role_id' => 'integer',
- 'department_id' => 'integer',
- 'remark' => 'length:0,100',
- 'old_password' => 'require|min:6',
- 'password_confirmation' => 'require|min:6|confirm:password',
- ];
- /**
- * 参数描述
- * @var string[]
- */
- protected $field = [
- 'id' => 'id',
- 'username' => '账号',
- 'nickname' => '昵称',
- 'password' => '密码',
- 'phone' => '手机号',
- 'email' => '邮箱',
- 'sex' => '性别',
- 'role_id' => '角色ID',
- 'department_id' => '部门ID',
- 'remark' => '备注',
- 'old_password' => '旧密码',
- 'password' => '新密码',
- 'password_confirmation' => '确认密码',
- ];
- /**
- * @notes 添加场景
- */
- public function sceneAdd()
- {
- return $this->only(['username', 'nickname', 'password', 'phone', 'email', 'sex', 'role_id', 'department_id', 'remark']);
- }
- /**
- * @notes 编辑场景
- */
- public function sceneEdit()
- {
- return $this->only(['id','username', 'nickname', 'password', 'phone', 'email', 'sex', 'role_id', 'department_id', 'remark']);
- }
- public function sceneDel()
- {
- return $this->only(['id']);
- }
- public function scenePassword()
- {
- return $this->only(['old_password','password','password_confirmation']);
- }
- public function sceneLogin()
- {
- return $this->only(['username','password']);
- }
- }
|