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