PHPackages                             gicminos/chat - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. gicminos/chat

ActiveLibrary

gicminos/chat
=============

Fork of musonza/chat to mantain version 3 in future laravel releases

v3.8.2(5y ago)11.7kMITPHPPHP &gt;=7.3CI failing

Since Mar 18Pushed 5y agoCompare

[ Source](https://github.com/Gicminos/chat)[ Packagist](https://packagist.org/packages/gicminos/chat)[ RSS](/packages/gicminos-chat/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (44)Used By (0)

[![chat](menu.png)](menu.png)

[![Build Status](https://camo.githubusercontent.com/7342bb20f040d8e13e22161b0e2de27b68e6293e0a535c9de569980683dbbe5e/68747470733a2f2f7472617669732d63692e6f72672f6d75736f6e7a612f636861742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/musonza/chat)[![Downloads](https://camo.githubusercontent.com/b3eb9da5bb7ba50fc0e04470be89bc6fa455ea7a02f76c934199b8966be876c2/68747470733a2f2f706f7365722e707567782e6f72672f6d75736f6e7a612f636861742f642f746f74616c2e737667)](https://packagist.org/packages/musonza/chat)[![Packagist](https://camo.githubusercontent.com/b4322a34bf14abd45101cc2050e9faf8ed0691350508e537821e91ad4241bfb6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d75736f6e7a612f636861742e737667)](https://packagist.org/packages/musonza/chat)

Chat
----

[](#chat)

[Demo Application](https://github.com/musonza/chat-demo)

Want to use any Laravel model as Chat participant? Follow this PR [musonza#163](https://github.com/musonza/chat/pull/163)

- [Introduction](#introduction)
- [Installation](#installation)
- [Usage](#usage)
    - [Creating a conversation](#creating-a-conversation)
    - [Get a conversation by Id](#get-a-conversation-by-id)
    - [Update conversation details](#update-conversation-details)
    - [Send a text message](#send-a-text-message)
    - [Send a message of custom type](#send-a-message-of-custom-type)
    - [Get a message by id](#get-a-message-by-id)
    - [Mark a message as read](#mark-a-message-as-read)
    - [Mark whole conversation as read](#mark-whole-conversation-as-read)
    - [Unread messages count](#unread-messages-count)
    - [Delete a message](#delete-a-message)
    - [Clear a conversation](#clear-a-conversation)
    - [Get a conversation between two users](#get-a-conversation-between-two-users)
    - [Get common conversations among users](#get-common-conversations-among-users)
    - [Remove users from a conversation](#remove-users-from-a-conversation)
    - [Add users to a conversation](#add-users-to-a-conversation)
    - [Get messages in a conversation](#get-messages-in-a-conversation)
    - [Get recent messages](#get-recent-messages)
    - [Get users in a conversation](#get-users-in-a-conversation)
- [License](#license)

Introduction
------------

[](#introduction)

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

Installation
------------

[](#installation)

From the command line, run:

```
composer require musonza/chat

```

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

```
Musonza\Chat\ChatServiceProvider::class

```

Add the Facade to your aliases:

```
'Chat' => Musonza\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 `musonza_chat.php` in the Laravel config folder.

Configuration
-------------

[](#configuration)

```
return [
    'user_model' => 'App\User',

    /**
     * If not set, the package will use getKeyName() on the user_model specified above
     */
    'user_model_primary_key' => null,

    /*
     * This will allow you to broadcast an event when a message is sent
     * Example:
     * Channel: mc-chat-conversation.2,
     * Event: Musonza\Chat\Eventing\MessageWasSent
     */
    'broadcasts' => false,

    /**
     * The event to fire when a message is sent
     * See Musonza\Chat\Eventing\MessageWasSent if you want to customize.
     */
    'sent_message_event' => 'Musonza\Chat\Eventing\MessageWasSent',

    /**
     * Automatically convert conversations with more than two users to public
     */
    'make_three_or_more_users_public' => true,
];
```

Run the migrations:

```
php artisan migrate

```

Usage
-----

[](#usage)

By default the package assumes you have a User model in the App namespace.

However, you can update the user model in `musonza_chat.php` published in the `config` folder.

#### Creating a conversation

[](#creating-a-conversation)

```
$participants = [$userId, $userId2,...];

$conversation = Chat::createConversation($participants);
```

#### Creating a conversation of type private / public

[](#creating-a-conversation-of-type-private--public)

```
$participants = [$userId, $userId2,...];

// Create a private conversation
$conversation = Chat::createConversation($participants)->makePrivate();

// Create a public conversation
$conversation = Chat::createConversation($participants)->makePrivate(false);
```

#### Get a conversation by id

[](#get-a-conversation-by-id)

```
$conversation = Chat::conversations()->getById($id);
```

#### Update conversation details

[](#update-conversation-details)

```
$data = ['title' => 'PHP Channel', 'description' => 'PHP Channel Description'];
$conversation->update(['data' => $data]);
```

#### Send a text message

[](#send-a-text-message)

```
$message = Chat::message('Hello')
            ->from($user)
            ->to($conversation)
            ->send();
```

#### Send a message of custom type

[](#send-a-message-of-custom-type)

The default message type is `text`. If you want to specify custom type you can call the `type()` function as below:

```
$message = Chat::message('http://example.com/img')
		->type('image')
		->from($user)
		->to($conversation)
		->send();
```

### Get a message by id

[](#get-a-message-by-id)

```
$message = Chat::messages()->getById($id);
```

#### Mark a message as read

[](#mark-a-message-as-read)

```
Chat::message($message)->setUser($user)->markRead();
```

#### Flag / mark a message

[](#flag--mark-a-message)

```
Chat::message($message)->setUser($user)->toggleFlag();

Chat::message($message)->setUser($user)->flagged(); // true
```

#### Mark whole conversation as read

[](#mark-whole-conversation-as-read)

```
Chat::conversation($conversation)->setUser($user)->readAll();
```

#### Unread messages count

[](#unread-messages-count)

```
$unreadCount = Chat::messages()->setUser($user)->unreadCount();
```

#### Unread messages count per Conversation

[](#unread-messages-count-per-conversation)

```
Chat::conversation($conversation)->setUser($user)->unreadCount();
```

#### Delete a message

[](#delete-a-message)

```
Chat::message($message)->setUser($user)->delete();
```

#### Clear a conversation

[](#clear-a-conversation)

```
Chat::conversation($conversation)->setUser($user)->clear();
```

#### Get a conversation between two users

[](#get-a-conversation-between-two-users)

```
$conversation = Chat::conversations()->between($user1, $user2);
```

#### Get common conversations among users

[](#get-common-conversations-among-users)

```
$conversations = Chat::conversations()->common($users);
```

`$users` can be an array of user ids ex. `[1,4,6]` or a collection `(\Illuminate\Database\Eloquent\Collection)` of users

#### Remove users from a conversation

[](#remove-users-from-a-conversation)

```
/* removing one user */
Chat::conversation($conversation)->removeParticipants($user);
```

```
/* removing multiple users */
Chat::conversation($conversation)->removeParticipants([$user1, $user2, $user3,...,$userN]);
```

#### Add users to a conversation

[](#add-users-to-a-conversation)

```
/* add one user */
Chat::conversation($conversation)->addParticipants($user);
```

```
/* add multiple users */
Chat::conversation($conversation)->addParticipants([$user3, $user4]);
```

**Note:** By default, a third user will classify the conversation as not private if it was. See config on how to change this.

#### Get messages in a conversation

[](#get-messages-in-a-conversation)

```
Chat::conversation($conversation)->setUser($user)->getMessages()
```

#### Get user conversations by type

[](#get-user-conversations-by-type)

```
// private conversations
$conversations = Chat::conversations()->setUser($user)->isPrivate()->get();

// public conversations
$conversations = Chat::conversations()->setUser($user)->isPrivate(false)->get();

// all conversations
$conversations = Chat::conversations()->setUser($user)->get();
```

#### Get recent messages

[](#get-recent-messages)

```
$messages = Chat::conversations()->setUser($user)->limit(25)->page(1)->get();
```

Example

```
[
      "id" => 1
      "private" => "1"
      "data" => []
      "created_at" => "2018-06-02 21:35:52"
      "updated_at" => "2018-06-02 21:35:52"
      "last_message" => array:13 [
        "id" => 2
        "message_id" => "2"
        "conversation_id" => "1"
        "user_id" => "1"
        "is_seen" => "1"
        "is_sender" => "1"
        "flagged" => false
        "created_at" => "2018-06-02 21:35:52"
        "updated_at" => "2018-06-02 21:35:52"
        "deleted_at" => null
        "body" => "Hello 2"
        "type" => "text"
        "sender" => array:7 [
          "id" => 1
          "name" => "Jalyn Ernser"
          "email" => "colt.howell@example.com"
        ]
      ]
    ]

```

#### Pagination

[](#pagination)

There are a few ways you can achieve pagination You can specify the `limit` and `page` as above using the respective functions or as below:

```
   $paginated = Chat::conversations()->setUser($user)
            ->setPaginationParams([
                'page' => 3,
                'perPage' => 10,
                'sorting' => "desc",
                'columns' => [
                    '*'
                ],
                'pageName' => 'test'
            ])
            ->get();

```

You don't have to specify all the parameters. If you leave the parameters out, default values will be used. `$paginated` above will return `Illuminate\Pagination\LengthAwarePaginator`To get the `conversations` simply call `$paginated->items()`

#### Get users in a conversation

[](#get-users-in-a-conversation)

```
$users = $conversation->users;
```

License
-------

[](#license)

Chat is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~49 days

Recently: every ~119 days

Total

37

Last Release

1914d ago

Major Versions

v0.1 → v1.0.02017-07-16

v1.0.0 → v2.0.02017-07-22

v2.1.2 → v3.0.02018-06-02

PHP version history (5 changes)v2.0.0PHP &gt;=5.6.0

v3.0.0PHP &gt;=7.0

v3.6.0PHP ^7.2

3.0.x-devPHP ^7.1.3|^7.2

v3.8.1PHP &gt;=7.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/b8e0802d19d9fd55d08c5db6d9baa1cfe279a120af077f599ff0b7b771b498ab?d=identicon)[Gicminos](/maintainers/Gicminos)

---

Top Contributors

[![Gicminos](https://avatars.githubusercontent.com/u/9993624?v=4)](https://github.com/Gicminos "Gicminos (10 commits)")[![musonza](https://avatars.githubusercontent.com/u/3452388?v=4)](https://github.com/musonza "musonza (7 commits)")[![moecasts](https://avatars.githubusercontent.com/u/37169906?v=4)](https://github.com/moecasts "moecasts (2 commits)")[![sonnysantino](https://avatars.githubusercontent.com/u/1275605?v=4)](https://github.com/sonnysantino "sonnysantino (2 commits)")[![BenQoder](https://avatars.githubusercontent.com/u/24754078?v=4)](https://github.com/BenQoder "BenQoder (1 commits)")[![danilopinotti](https://avatars.githubusercontent.com/u/11338999?v=4)](https://github.com/danilopinotti "danilopinotti (1 commits)")[![flyingcoder](https://avatars.githubusercontent.com/u/8900451?v=4)](https://github.com/flyingcoder "flyingcoder (1 commits)")[![abhishekpaul](https://avatars.githubusercontent.com/u/1397474?v=4)](https://github.com/abhishekpaul "abhishekpaul (1 commits)")[![mirzazulfan](https://avatars.githubusercontent.com/u/36124339?v=4)](https://github.com/mirzazulfan "mirzazulfan (1 commits)")[![MostafaNobaghi](https://avatars.githubusercontent.com/u/24896868?v=4)](https://github.com/MostafaNobaghi "MostafaNobaghi (1 commits)")[![owenvoke](https://avatars.githubusercontent.com/u/1899334?v=4)](https://github.com/owenvoke "owenvoke (1 commits)")[![rez1dent3](https://avatars.githubusercontent.com/u/5111255?v=4)](https://github.com/rez1dent3 "rez1dent3 (1 commits)")[![leohubert](https://avatars.githubusercontent.com/u/13404544?v=4)](https://github.com/leohubert "leohubert (1 commits)")[![AleksandarSavic95](https://avatars.githubusercontent.com/u/12213798?v=4)](https://github.com/AleksandarSavic95 "AleksandarSavic95 (1 commits)")[![aren1989](https://avatars.githubusercontent.com/u/10001337?v=4)](https://github.com/aren1989 "aren1989 (1 commits)")[![axe1987](https://avatars.githubusercontent.com/u/25763733?v=4)](https://github.com/axe1987 "axe1987 (1 commits)")

---

Tags

laravelmessagingchatconversation

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/gicminos-chat/health.svg)

```
[![Health](https://phpackages.com/badges/gicminos-chat/health.svg)](https://phpackages.com/packages/gicminos-chat)
```

###  Alternatives

[musonza/chat

Chat Package for Laravel

1.2k253.4k1](/packages/musonza-chat)[lexxyungcarter/chatmessenger

Simple one-to-one/group chat messaging tool for Laravel 5, 6, 7, 8, 9 &amp; 10 with Pusher Integration

10724.1k](/packages/lexxyungcarter-chatmessenger)[scriptdevelop/whatsapp-manager

Paquete para manejo de WhatsApp Business API en Laravel

762.6k](/packages/scriptdevelop-whatsapp-manager)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
