1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace app\common\model;
- use think\Model;
- use app\common\library\Easemob;
- /**
- * 系统消息模型
- */
- class Message extends Model
- {
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- /**
- * 添加系统消息
- */
- public static function addMessage($user_id,$title,$content,$infotype = '',$infotype_id = 0) {
- if(!$user_id || !$title || !$content) {
- return false;
- }
- //推送
- //$easemob = new Easemob();
- //$easemob->push_text($user_id,$title,$content);
- //入库
- $data = [];
- $data["user_id"] = $user_id;
- $data["title"] = $title;
- $data["content"] = $content;
- $data["createtime"] = time();
- $data["status"] = 0;
- $data["infotype"] = $infotype;
- $data["infotype_id"] = $infotype_id;
- return self::insertGetId($data);
- }
- }
|