<?php

namespace app\admin\model;

use support\Model;

class SmsRecord extends Model
{
    /**
     * 短信发送记录表
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'sms_record';

    /**
     * The primary key associated with the table.
     *
     * @var string
     */
    protected $primaryKey = 'record_id';

    /**
     * Indicates if the model should be timestamped.
     *
     * @var bool
     */

    /**
     * Notes:插入验证码数据
     * @param int $mobile
     * @param string $message
     * @param string $template_id
     * @param int $user_id
     * @return int
     * User: yym
     * Date: 2022/7/23
     */
    public static function InsertData(int $mobile, string $message, string $template_id, int $user_id = 0)
    {
        $insert = array(
            'record_user_id' => $user_id,
            'record_phone'   => $mobile,
            'record_ip'      => get_ip(),
            'record_template' => $template_id,
            'record_content' => $message,
            'record_create_time' => time(),
            'record_update_time' => time()
        );
        return static::insertGetId($insert);
    }
}
