78 lines
2.1 KiB
PHP
78 lines
2.1 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace App\Model;
|
||
|
||
|
||
|
||
use Hyperf\Snowflake\Concern\Snowflake;
|
||
|
||
/**
|
||
* @property int $code_log_id 主键id
|
||
* @property int $type 类型(1:短信 2:邮件)
|
||
* @property int $status 状态(1:发送成功 2:发送失败)
|
||
* @property int $scene 场景(1:登陆)
|
||
* @property string $phone 手机号
|
||
* @property string $code 验证码
|
||
* @property string $third_code 第三方编码
|
||
* @property string $remarks 备注
|
||
* @property \Carbon\Carbon $created_at 创建时间
|
||
* @property \Carbon\Carbon $updated_at 修改时间
|
||
*/
|
||
class CodeLog extends Model
|
||
{
|
||
use Snowflake;
|
||
|
||
/**
|
||
* The table associated with the model.
|
||
*/
|
||
protected ?string $table = 'code_log';
|
||
|
||
/**
|
||
* The attributes that are mass assignable.
|
||
*/
|
||
protected array $fillable = ['code_log_id', 'type', 'status', 'scene', 'phone', 'code', 'third_code', 'remarks', 'created_at', 'updated_at'];
|
||
|
||
/**
|
||
* The attributes that should be cast to native types.
|
||
*/
|
||
protected array $casts = ['code_log_id' => 'integer', 'type' => 'integer', 'status' => 'integer', 'scene' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];
|
||
|
||
protected string $primaryKey = "code_log_id";
|
||
|
||
/**
|
||
* 获取信息-单条
|
||
* @param array $params
|
||
* @param array $fields
|
||
* @return object|null
|
||
*/
|
||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||
{
|
||
return self::where($params)->first($fields);
|
||
}
|
||
|
||
/**
|
||
* 获取信息-多条
|
||
* @param array $params
|
||
* @param array $fields
|
||
* @param string $order
|
||
* @param string $direction
|
||
* @return object|null
|
||
*/
|
||
public static function getList(array $params, array $fields = ['*']): object|null
|
||
{
|
||
return self::where($params)->get($fields);
|
||
}
|
||
|
||
/**
|
||
* 新增-批量
|
||
* @param array $data
|
||
* @return \Hyperf\Database\Model\Model|CodeLog
|
||
*/
|
||
public static function addCodeLog(array $data): \Hyperf\Database\Model\Model|CodeLog
|
||
{
|
||
return self::create($data);
|
||
}
|
||
}
|