Message.php 985 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. use app\common\library\Easemob;
  5. /**
  6. * 系统消息模型
  7. */
  8. class Message extends Model
  9. {
  10. // 开启自动写入时间戳字段
  11. protected $autoWriteTimestamp = 'int';
  12. // 定义时间戳字段名
  13. protected $createTime = 'createtime';
  14. /**
  15. * 添加系统消息
  16. */
  17. public static function addMessage($user_id,$title,$content,$infotype = '',$infotype_id = 0) {
  18. if(!$user_id || !$title || !$content) {
  19. return false;
  20. }
  21. //推送
  22. //$easemob = new Easemob();
  23. //$easemob->push_text($user_id,$title,$content);
  24. //入库
  25. $data = [];
  26. $data["user_id"] = $user_id;
  27. $data["title"] = $title;
  28. $data["content"] = $content;
  29. $data["createtime"] = time();
  30. $data["status"] = 0;
  31. $data["infotype"] = $infotype;
  32. $data["infotype_id"] = $infotype_id;
  33. return self::insertGetId($data);
  34. }
  35. }