定制 vns/chatting 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vns/chatting

最新稳定版本:0.3.0

Composer 安装命令:

composer require vns/chatting

包简介

api for make chatting easy

README 文档

README

Latest Version on Packagist Total Downloads GitHub Actions

small package to do task of any chatting task like manage conversations, messages, participants, ...

Installation

You can install the package via composer:

composer require vns/chatting-api

Usage

First You Must Publish migrations

php artisan vendor:publish --provider="VnsChattingApi\ChattingApiServiceProvider" --tag="migrations"

Publish config file

php artisan vendor:publish --provider="VnsChattingApi\ChattingApiServiceProvider" --tag="config"

Add Messageable Trait for participant model

use VnsChattingApi\Traits\Messageable;

Manage Conversation

// Create new Conversation
ChattingApiFacade::createConversation([$model1,$model2]); // create un-direct conversation
ChattingApiFacade::createDirectConversation([$model1,$model2]); // create direct conversation


// Get conversation by id
ChattingApiFacade::conversations()->getById($conversation_id);


// Get conversation messages
ChattingApiFacade::conversation($conversation)->setParticipant($participant)
            ->setPaginationParams([
                'page' => 1,
                'perPage' => 25,
                'sorting' => "desc",
                'columns' => [
                    '*'
                ],
                'pageName' => 'page'
            ])
            ->page($page)
            ->getMessages();

// OR

$participant->conversations;

// Get Count of unread messages for conversations for specific participant
ChattingApiFacade::conversation($conversation)->setParticipant($participant)->unreadCount();


// Get Conversation between two participant
ChattingApiFacade::conversations()->between( $participantOne,  $participantTwo);


// Clear all message notifications for one participant
ChattingApiFacade::conversations()->setParticipant($participant)->clear();


// Make all Messages as read by specific participant
ChattingApiFacade::conversations()->setParticipant($participant)->readAll();


// Add new participants for conversation
ChattingApiFacade::conversation($conversation)->addParticipants($participants);


// Remove participants from conversation
ChattingApiFacade::conversation($conversation)->removeParticipants($participants);

conversations api

Manage Participant

// added Messageable Trait for participant model
use VnsChattingApi\Traits\Messageable;


// Get all conversations for participant
$participant->conversations();


// Join Conversation
$participant->joinConversation($conversation);


// leave Conversation
$participant->leaveConversation($conversation);

Manage Message

// Create new Message
ChattingApiFacade::message('message content')
        ->from($participant)
        ->to($conversation)
        ->send();

// Or

ChattingApiFacade::message('message content')
    ->from($participant)
    ->to($conversation)
    ->type('text')
    ->send();


// Delete Message For Specific Participant
ChattingApiFacade::messages()->getById($message_id)->trash($participant);

统计信息

  • 总下载量: 6
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-10-05