chareice / laravel-chat
Chat Package for laravel
dev-main
2022-05-23 13:11 UTC
Requires
- php: >=8.0
- laravel/framework: ^9.0
- spatie/laravel-ray: ^1.29
Requires (Dev)
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.2
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-11-22 05:48:58 UTC
README
为Laravel提供消息(私信)服务
安装
composer require chareice/laravel-chat
使用
class User extends Model implements ChatAbleContract { use ChatAble; } /** @var User $a */ $a = User::query()->create([ 'name' => 'user1', 'avatar' => 'user1-avatar' ]); /** @var User $b */ $b = User::query()->create([ 'name' => 'user2', 'avatar' => 'user2-avatar' ]); // A用户给B发送消息 $a->sendMessage('test', 'text', $b); /** @var ChatSession $bSession */ $bSession = $b->chatSessions()->first(); // b的session存在1条未读消息 $bSession->unreadMessageCount();