SmsLog.php
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2023/6/3
* Time: 17:42
*/
namespace App\Models\Sms;
use App\Models\Base;
class SmsLog extends Base
{
//设置关联表名
protected $table = 'gl_sms_log';
const TYPE_REGISTER = 'register';
const TYPE_LOGIN = 'login';
const TYPE_MANAGER_LOGIN = 'manager_login';//管理员登录
const TYPE_NOTICE = 'notice';
const USE_USABLE = 0;
const USE_DISABLE = 1;
/**
* 创建日志
* @param $mobile
* @param $code
* @param $type
* @param string $content
* @return mixed
*/
public static function createLog($mobile, $code, $type = self::TYPE_LOGIN, $content = '')
{
$created_at = $updated_at = date('Y-m-d H:i:s',time() + 8 * 60 * 60);
$array = compact('type', 'mobile', 'code', 'content', 'updated_at', 'created_at');
return self::insert($array);
}
/**
* 查询最后一条日志
* @param $mobile
* @param $type
* @return mixed
*/
public static function getLastLog($mobile, $type)
{
return self::where(compact('type', 'mobile'))->orderBy('id', 'desc')->first();
}
}