| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- namespace app\workerapi\validate;
- use app\common\enum\notice\NoticeEnum;
- use app\common\service\sms\SmsDriver;
- use app\common\validate\BaseValidate;
- /**
- * @author 林海涛
- * @date 2024/7/10 下午1:42
- */
- class MasterWokerValidate extends BaseValidate
- {
- protected $rule = [
- 'mobile' => 'require|mobile',
- 'code' => 'require|checkCode',
- 'password' => 'require|length:6,20|alphaNum',
- 'password_confirm' => 'require|confirm',
- 'field' => 'require|checkField',
- 'value' => 'require',
- ];
- protected $message = [
- 'mobile.require' => '请输入手机号',
- 'mobile.mobile' => '请输入正确手机号',
- 'code.require' => '请填写验证码',
- 'password.require' => '请输入密码',
- 'password.length' => '密码须在6-25位之间',
- 'password.alphaNum' => '密码须为字母数字组合',
- 'password_confirm.require' => '请确认密码',
- 'password_confirm.confirm' => '两次输入的密码不一致',
- 'field.require' => '参数缺失',
- 'value.require' => '值不存在',
- ];
- protected function checkField($value, $rule, $data)
- {
- $allowField = [
- 'nickname', 'sex', 'real_avatar','avatar', 'real_name','accept_order_status',
- ];
- if (!in_array($value, $allowField)) {
- return '参数错误';
- }
- return true;
- }
- public function checkCode($code, $rule, $data)
- {
- $smsDriver = new SmsDriver();
- $result = $smsDriver->verify($data['mobile'], $code, NoticeEnum::CHANGE_MOBILE_CAPTCHA);
- if ($result) {
- return true;
- }
- return true;
- //return '验证码错误';
- }
- public function sceneChangeMobile(){
- return $this->only(['mobile', 'code']);
- }
- public function sceneChangePassword()
- {
- return $this->only(['password', 'password_confirm']);
- }
- public function sceneSetInfo()
- {
- return $this->only(['field', 'value']);
- }
- public function sceneInterview()
- {
- return $this->only(['sys_uuid', 'worker_id','nickname','status','start_answer','answer','answer1','answer2','answer3','answer4','answer5','answer6','answer7','answer8','answer9','answer10','question_answer']);
- }
- public function sceneQuestion()
- {
- return $this->only(['category']);
- }
- public function sceneGetInterview()
- {
- return $this->only(['worker_id']);
- }
- public function sceneGetRegInfo()
- {
- return $this->only(['user']);
- }
- }
|