<?php
namespace app\model;

use think\Model;


class Sms extends Model
{
    protected $table = "jm_sms";


    /**
     * 检测验证码
     */
    public static function checkSmsCode($phone , $code , $type = 1):string
    {
        $sms = Sms::where(['phone' => $phone , 'code' => $code])->find();
        if(empty($sms)) {
            return 'code-error';
        }

        if(time() - $sms['createtime'] >= 600) {
            return 'code-timeout';
        }
        return 'success';
    }
}
