定制 deskti/laravel-chat 二次开发

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

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

deskti/laravel-chat

Composer 安装命令:

composer require deskti/laravel-chat

包简介

Laravel chat package

README 文档

README

This package allows you to add a chat system to your Laravel 5 application

Obs: Chat copiado do musonza/chat apenas para o uso pessoal da Deskti

Installation

From the command line, run:

composer require deskti/laravel-chat

Add the service provider to your config\app.php the providers array

Deskti\Chat\ChatServiceProvider

You can use the facade for shorter code. Add this to your aliases:

'Chat' => Deskti\Chat\Facades\ChatFacade::class to your `config\app.php`

The class is bound to the ioC as chat

$chat = App::make('chat');

Publish the assets:

php artisan vendor:publish

This will publish database migrations and a configuration file chat.php in the Laravel config folder.

Usage

By default the package assumes you have a User model in the App namespace. However, you can update the user model in 'chat.php' published in the config folder.

Creating a conversation

$conversation = Chat::createConversation([$userId, $userId2,...]); //takes an array of user ids

Get a conversation given a conversation_id

$conversation = Chat::conversation($conversation_id);

Send a message

Chat::send($conversation->id, 'Hello', $userId); //$userId sending a message to created conversation

Mark message as read

Chat::messageRead($messageId, $userId); //$userId marks the mesage as read

Mark whole conversation as read

Chat::conversationRead($conversation->id, $userId);

Delete a message

Chat::trash($messageId, $userId);

Clear a conversation

Chat::clear($conversation->id, $userId);

Get conversation for two users

Chat::getConversationBetweenUsers($userId, $userId2);

Remove user(s) from conversation

Chat::removeParticipants($conversation->id, $usersId); //removing one user
Chat::removeParticipants($conversation->id, [$usersId, $userId2]); //removing multiple users

Add user(s) to a conversation

Chat::addParticipants($conversation->id, $userId3); //add one user
Chat::addParticipants($conversation->id, [$userId3, $userId4]); //add multiple users

Get messages in a conversation

Chat::messages($userId, $conversation->id, $perPage, $page);

Get recent messages

$mesages = Chat::conversations($userId);

Get users in a conversation

$users = $conversation->users;

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-05-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固