| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- // +----------------------------------------------------------------------
- // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
- // +----------------------------------------------------------------------
- // | 版权所有 2017~2021 LARAVEL研发中心
- // +----------------------------------------------------------------------
- // | 官方网站: http://www.laravel.cn
- // +----------------------------------------------------------------------
- // | Author: laravel开发员 <laravel.qq.com>
- // +----------------------------------------------------------------------
- namespace App\Services;
- use App\Models\ChatMessageModel;
- use App\Models\ConfigModel;
- /**
- * 聊天-服务类
- * Class ChatMessageService
- * @package App\Services
- */
- class ChatMessageService extends BaseService
- {
- // 静态对象
- protected static $instance = null;
- /**
- * 构造函数
- * ChatMessageService constructor.
- */
- public function __construct()
- {
- $this->model = new ChatMessageModel();
- }
- /**
- * 静态入口
- * @return static|null
- */
- public static function make(){
- if(!self::$instance){
- self::$instance = (new static());
- }
- return self::$instance;
- }
- /**
- * 聊天对话窗口唯一KEY
- * @param $fromUid
- * @param $toUid
- * @return string
- */
- public function getChatKey($fromUid, $toUid)
- {
- $chatKeys = [$fromUid, $toUid];
- asort($chatKeys);
- return implode('', $chatKeys);
- }
- /**
- * 推送保存消息,如订单消息
- * @param $data 消息数据
- * @return int|number
- */
- public function pushMessage($data)
- {
- return $this->model->edit($data);
- }
- }
|