Files
tuiguangzhushou/application/common/validate/Sms.php
2020-08-06 15:26:41 +08:00

55 lines
1.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\validate;
use think\Db;
use think\Validate;
use tools\Verify;
class Sms extends Validate
{
/**
* 验证规则
* @var array
*/
protected $rule = [
'mobile' => 'require|checkMobile:|checkTimes:',
'code' => 'require|length:4,6',
];
/**
* 错误提示消息
* @var array
*/
protected $message = [
'mobile.require' => '手机号码 必须填写',
'mobile.checkMobile' => '手机号码 格式有误',
'code.require' => '验证码 必须填写',
'code.length' => '验证码 长度有误',
];
protected $scene = [
];
protected function checkTimes($value)
{
if (time() - Db::name('Sms')->where('mobile', $value)->order('id desc')->value('create_time') < 60) {
return '发送频率过快';
} else {
return true;
}
}
protected function checkMobile($value)
{
return Verify::isMobilePhone($value);
}
}