input('mobile'); if ($m === '' || $m === null) { $this->merge(['mobile' => null]); } } /** * @return array */ public function rules(): array { return [ 'mobile' => [ 'nullable', 'string', 'max:20', 'regex:/^1[3-9]\d{9}$/', Rule::unique('reviewers', 'mobile'), ], 'name' => ['required', 'string', 'max:64'], 'username' => ['required', 'string', 'max:64', 'regex:/^[A-Za-z0-9._-]+$/', Rule::unique('reviewers', 'username')], 'password' => ['required', 'string', 'min:6', 'max:255'], 'status' => ['sometimes', 'string', Rule::in(['active', 'disabled'])], ]; } /** * @return array */ public function attributes(): array { return [ 'mobile' => '手机号', 'name' => '姓名', 'status' => '状态', 'username' => '账户', 'password' => '密码', ]; } /** * @return array */ public function messages(): array { return [ 'username.regex' => ':attribute 仅可为字母、数字、点、横线或下划线。', ]; } }