77 lines
2.2 KiB
PHP
77 lines
2.2 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace App\Model;
|
||
|
||
|
||
|
||
use Hyperf\Database\Model\Collection;
|
||
use Hyperf\Snowflake\Concern\Snowflake;
|
||
|
||
/**
|
||
* @property int $push_id 主键id
|
||
* @property int $push_user_id 用户id(被推送者)
|
||
* @property int $event 推送事件(具体定义查看消费端)
|
||
* @property string $wx_template_id 微信推送模版id
|
||
* @property string $params 推送所需的参数(json)
|
||
* @property int $status 推送状态(1:成功 2:失败)
|
||
* @property string $fail_reason 推送失败原因
|
||
* @property string $content 推送内容
|
||
* @property \Carbon\Carbon $created_at 创建时间
|
||
* @property \Carbon\Carbon $updated_at 修改时间
|
||
*/
|
||
class LogMessagePush extends Model
|
||
{
|
||
use Snowflake;
|
||
|
||
/**
|
||
* The table associated with the model.
|
||
*/
|
||
protected ?string $table = 'log_message_push';
|
||
|
||
/**
|
||
* The attributes that are mass assignable.
|
||
*/
|
||
protected array $fillable = ['push_id', 'push_user_id', 'event', 'wx_template_id', 'params', 'status', 'fail_reason', 'content', 'created_at', 'updated_at'];
|
||
|
||
/**
|
||
* The attributes that should be cast to native types.
|
||
*/
|
||
protected array $casts = ['push_id' => 'integer', 'push_user_id' => 'integer', 'event' => 'integer', 'status' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];
|
||
|
||
protected string $primaryKey = "push_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
|
||
* @return Collection|array
|
||
*/
|
||
public static function getList(array $params = [], array $fields = ['*']): Collection|array
|
||
{
|
||
return self::where($params)->get($fields);
|
||
}
|
||
|
||
/**
|
||
* 新增
|
||
* @param array $data
|
||
* @return LogMessagePush|\Hyperf\Database\Model\Model
|
||
*/
|
||
public static function addLogMessagePush(array $data): LogMessagePush|\Hyperf\Database\Model\Model
|
||
{
|
||
return self::create($data);
|
||
}
|
||
}
|