zzwy2/app/model/SmsLog.php

30 lines
805 B
PHP
Executable File

<?php
namespace app\model;
/**
* 短信记录
* Class SmsLog
* @package app\model
*/
class SmsLog extends Base
{
public static $typeList = [
'resister' => 'reg',
'appointment' => 'appoint',
];
public static function countByPhone($phone, $starTime=0,$endTime=0, $type='')
{
return self::where('phone', $phone)
->when($starTime > 0, function ($query) use($starTime) {
$query->where('create_time', '>=', $starTime);
})
->when($endTime > 0, function ($query) use($endTime) {
$query->where('create_time', '<=', $endTime);
})
->when(!empty($type) && in_array($type, self::$typeList), function ($query) use($type) {
$query->where('type', $type);
})
->count();
}
}