metko/galera
Composer 安装命令:
composer require metko/galera
包简介
Messaging/chatting package for laravel
README 文档
README
Galera is small package to handle conversation between two or multiple user.
Installations
Step 1
composer require metko/galera
Step 2
Publish the config file and the asset
php artisan pusblish --tag:galera
How to use it
Usage
Use the trait
Use the trait Galerable in your user model
// Metko\Galera\Galerable; use Galerable;
Conversation
Create a conversation
Galera::participants($user1, $user2)->make(); *// Or pass an array of multiple user* Galera::addParticipants([1,2,3,'10'])->make();
Get a conversation
Galera::conversation($id); // Or with the messages Galera::conversation($id, true);
*Return a conversation with [‘messages_count’, ’unread_messages_count’] by default *
Clear a conversation
Galera::conversation($id)->clear();
Will soft delete all the message of the given conversation
Close a conversation
Galera::conversation($id)->close(); return Metko\Galera\Conversation
Nobody can submit a message in a close conversation
Check if a conversation is closed
Galera::conversation($id)->isCLosed(); // return bool
Add participants in a conversation
Galera::conversation($id)->add(1); // Or many user at the same time Galera::conversation($id)->addMany([1, $user2, '3']);
A Conversation can remove a participant
Galera::conversation($id)->remove(1);
A conversation must have at least 2 participants. It will return an error if you try to do it.
Read all message of a conversation
Galera::conversation($id)->readAll();
A conversation must have at least 2 participants. It will return an error if you try to do it.
User
A user can write a message
$user->write(‘My message’, $conversationId); // You can pass a model or an id for the conversation
Delete a message
Galera::message(1)->delete(); // You can pass a model or an id for the conversation param*
Write a message refering another
$user->write(‘My message’, $conversationId, $message->id); // You can pass a model or an id for the message param*
Check if a user has unread message on a specific conversation
$user->hasUnreadMessage($convzersationId); // Return bool //Or in all conversation where he is participant $user->hasUnreadMessage(); // Return bool
Get unread messages for user
$user->unreadMessages();
Read all the message unread for a user in a conversation
$user->readAll($convzersationId); // Return Collection
Return a list of all conversation ordered by updated_at, count of message, and unread_message_count
Get the last conversation of a user
$user->getLastConversation($withMessage = false, $nbMessage = 25); // Return Collection
Return a list of all conversation ordered by updated_at, count of message, and unread_message_count
Messagess
Get messages from a conversation
Galera::ofConversation($conversationId)->get();
Get a unread_message count in conversation
Galera::conversation($id)->unread_messages_count;
Get a total_message count n conversation
Galera::conversation($id)->messages_count;
Test cases
The package includes three test cases:
TestCase- Effectively the normal Laravel test case. Use it the same way you would your normal Laravel test caseSimpleTestCase- Extends the default PHPUnit test case, so it doesn’t set up a Laravel application, making it quicker and well-suited to properly isolated unit testsBrowserKitTestCase- Sets up BrowserKit
metko/galera 适用场景与选型建议
metko/galera 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 07 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「lumen」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 metko/galera 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 metko/galera 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 metko/galera 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Testing Suite For Lumen like Laravel does.
Stackdriver handler for Monolog (codeinternetapplications/monolog-stackdriver Fork).
Class to generate a standard structure for api json responses
Amqp classes
Audit changes of your Eloquent models in Laravel/Lumen
Laravel, Lumen and Native php elasticseach query builder to build complex queries using an elegant syntax
统计信息
- 总下载量: 18
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-07-02