84 lines
2.1 KiB
PHP
84 lines
2.1 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace App\Model;
|
||
|
||
|
||
|
||
use Hyperf\Database\Model\Collection;
|
||
use Hyperf\Snowflake\Concern\Snowflake;
|
||
|
||
/**
|
||
* @property int $log_id 主键id
|
||
* @property int $to_user_id 用户id(被推送者)
|
||
* @property int $user_type 用户类型(1:患者 2:医师 3:药师)
|
||
* @property int $type 推送类型(1:站内 2:短信 3:订阅)
|
||
* @property int $status 推送状态(1:成功 2:失败)
|
||
* @property string $fail_reason 推送失败原因
|
||
* @property string $send_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 = ['log_id', 'to_user_id', 'user_type', 'type', 'status', 'fail_reason', 'content', 'created_at', 'updated_at'];
|
||
|
||
protected string $primaryKey = "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
|
||
* @return Collection|array
|
||
*/
|
||
public static function getList(array $params = [], array $fields = ['*']): Collection|array
|
||
{
|
||
return self::where($params)->get($fields);
|
||
}
|
||
|
||
/**
|
||
* 修改
|
||
* @param array $params
|
||
* @param array $data
|
||
* @return int
|
||
*/
|
||
public static function edit(array $params = [], array $data = []): int
|
||
{
|
||
return self::where($params)->update($data);
|
||
}
|
||
|
||
/**
|
||
* 新增
|
||
* @param array $data
|
||
* @return LogMessagePush|\Hyperf\Database\Model\Model
|
||
*/
|
||
public static function addLogMessagePush(array $data): LogMessagePush|\Hyperf\Database\Model\Model
|
||
{
|
||
return self::create($data);
|
||
}
|
||
|
||
}
|