PHPackages                             dominservice/laravel\_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. [Utility &amp; Helpers](/categories/utility)
4. /
5. dominservice/laravel\_chat

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

dominservice/laravel\_chat
==========================

users messaging system

2.1.0(5y ago)138MITPHPPHP &gt;=7.1.3

Since Aug 12Pushed 5y ago1 watchersCompare

[ Source](https://github.com/dominservice/laravel_chat)[ Packagist](https://packagist.org/packages/dominservice/laravel_chat)[ Docs](https://github.com/dominservice/laravel_chat)[ RSS](/packages/dominservice-laravel-chat/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (10)Dependencies (1)Versions (13)Used By (0)

[![Latest Version](https://camo.githubusercontent.com/d93694606a6e8103c35586eb0b3179d03c6260b80f8009d5afd698f2866efd2c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f646f6d696e736572766963652f6c61726176656c5f636861742e7376673f7374796c653d666c61742d737175617265)](https://github.com/dominservice/laravel_chat/releases)[![Total Downloads](https://camo.githubusercontent.com/5535aa87f4b1957bfc2c756f2ef934899f95a24279a8912e16c2d316464e02e7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f646f6d696e736572766963652f6c61726176656c5f636861742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dominservice/laravel_chat)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

Laravel Chat
============

[](#laravel-chat)

This package will allow you to add a full user messaging system into your Laravel application.

### Notice

[](#notice)

This package is for Laravel 5.6 | 5.7 | 5.8 | 6.\* | 7.\* | 8.\*

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

[](#installation)

```
composer require dominservice/laravel_chat

```

Or place manually in composer.json:

```
"require": {
    "dominservice/laravel_chat": "^2.0"
}

```

Run:

```
composer update

```

Add the service provider to `config/app.php`

```
'providers' => [
    Dominservice\LaravelChat\LaravelChatServiceProvider::class,
],

(...)

'aliases' => [
    'LaravelChat' => Dominservice\LaravelChat\Facade\LaravelChat::class,
]
```

Publish config:

```
php artisan vendor:publish --provider="Dominservice\LaravelChat\LaravelChatServiceProvider"

```

Migrate

```
php artisan migrate

```

Usage
=====

[](#usage)

#### Get User Conversations:

[](#get-user-conversations)

```
$convs = LaravelChat::getConversations($user_id);
```

This will return you a "Illuminate\\Support\\Collection" of "Dominservice\\LaravelChat\\Entities\\Conversation" objects. And foreach Conversation there, you will have the last message of the conversation, and the users of the conversation. Example:

```
foreach ( $convs as $conv ) {
    $getNumOfUsers = $conv->getNumOfUsers();
    $users = $conv->users; /* Collection */

    /* $lastMessage Dominservice\LaravelChat\Entities\Message */
    $lastMessage = $conv->getLastMessage();

    $senderId = $lastMessage->sender;
    $content = $lastMessage->content;
    $status = $lastMessage->status;
}
```

#### Get User specific conversation:

[](#get-user-specific-conversation)

```
$conv = LaravelChat::getConversationMessages($conv_id, $user_id);
```

This will return you a "Dominservice\\LaravelChat\\Entities\\Conversation" object. On the object you could get all messages, all users, conv\_id, and more, simply browse the object itself. Example:

```
foreach ( $conv->messages as $msg ) {
    $senderId = $msg->sender;
    $content = $msg->content;
    $status = $msg->status; /* Collection statuses for all users */
    $statusUser = $msg->statusForUser($userId = null);
}
```

#### Get the conversation id of a conversation between two users:

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

```
$conv = LaravelChat::getConversationByTwoUsers($userA_id, $userB_id);
```

Simply gives you an id of the conversation between two users, this was created for redirecting to the conversation page when user tries to send a message to another user, so if there is no id returned that means that those users has no conversation yet, so we could create one.

#### Add a new message to conversation:

[](#add-a-new-message-to-conversation)

```
$conv = LaravelChat::addMessageToConversation($conv_id, $user_id, $content);
```

Simply add a message to an exiting conversation, content is the message text.

#### Create a new conversation:

[](#create-a-new-conversation)

```
$conv = LaravelChat::createConversation($users_ids=array(), $relationType = null, $relationId = null);
```

Creates a new conversation with the users id's you passed in the array.

#### Get all users in conversation:

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

```
$conv = LaravelChat::getUsersInConversation($conv_id);
```

returns an array of user id in the conversation.

#### Delete conversation:

[](#delete-conversation)

```
$conv = LaravelChat::deleteConversation($conv_id, $user_id);
```

"Deletes" the conversation from a specifc user view.

#### Check if user is in conversation:

[](#check-if-user-is-in-conversation)

```
$conv = LaravelChat::isUserInConversation($conv_id, $user_id);
```

True or False if user is in conversation.

#### Get number of unread messages for specific user:

[](#get-number-of-unread-messages-for-specific-user)

```
$conv = LaravelChat::getNumOfUnreadMsgs($user_id);
```

return an integer of number of unread messages for specific user.

#### Mark all messages as "read" for specifc user in conversation:

[](#mark-all-messages-as-read-for-specifc-user-in-conversation)

```
$conv = LaravelChat::markReadAllMessagesInConversation($conv_id, $user_id);
```

### Example

[](#example)

```
public function conversations($convId=null) {
    $currentUser = Auth::user();
    //get the conversations
    $convs = LaravelChat::getConversations( $currentUser->id );
    //array for storing our users data, as that LaravelChat only provides user id's
    $users = [];

    //gathering users
    foreach ( $convs as $conv ) {
        $users = array_merge($users, $conv->getAllUsers());
    }
    //making sure each user appears once
    $users = array_unique($users);

    //getting all data of users
    if ( !empty($users) ) {
        $users = User::whereIn('id', $users)->with('profileImage')->getDictionary();
    }

    return View::make('conversations_page')
        ->with('users', $users)
        ->with('user', $currentUser)
        ->with('convs', $convs);
}
```

Helpers
-------

[](#helpers)

Get all conversations for user. If `userId` is `null` then set current user id.

```
get_conversations($userId = null);
```

Create conversations between selected users, in array must be `id` list.

```
set_conversation($users = []);
```

Delete conversations for user. If `userId` is `null` then set current user id.

```
delete_conversation($convId, $userId = null);
```

Check is user in conversations. If `userId` is `null` then set current user id.

```
in_conversation($convId, $userId = null);
```

Add message to conversations. If `userId` is `null` then set current user id.

```
conversation_add_message($convId, $content, $userId = null);
```

Add message to conversations between two users, it also create conversation if not exist, or add to exist. If `senderId` is `null` then set current user id.

```
conversation_add_message_between($content, $receiverId, $senderId = null);
```

Get count unread messages for user. If `userId` is `null` then set current user id.

```
conversation_unread_count($userId = null);
```

Get conversation between two users. If `senderId` is `null` then set current user id.

```
conversation_between($receiverId, $senderId = null);
```

Get conversation messages. If `userId` is `null` then set current user id.

```
conversation_messages($convId, $userId = null, $newToOld = true);
conversation_messages_unread($convId, $userId = null, $newToOld = true);
```

Mark messages. If `userId` is `null` then set current user id.

```
conversation_mark_as_archived($msgId, $userId = null);
conversation_mark_as_deleted($msgId, $userId = null);
conversation_mark_as_unread($msgId, $userId = null);
conversation_mark_as_read($msgId, $userId = null);

conversation_mark_as_read_all($convId, $userId = null);
conversation_mark_as_unread_all($convId, $userId = null);
```

Credits
=======

[](#credits)

[tzookb/tbmsg](https://github.com/tzookb/tbmsg)

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 84.3% of commits — single point of failure

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 ~15 days

Recently: every ~39 days

Total

12

Last Release

1982d ago

Major Versions

1.0.6 → 2.0.02020-08-26

PHP version history (3 changes)1.0.0PHP &gt;=7.2

2.0.2PHP &gt;=7.3

2.1.0PHP &gt;=7.1.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/9d67c041316385020aafb7eef9f11971d6fad80a11a44f4078273bda6890722d?d=identicon)[dominservice](/maintainers/dominservice)

---

Top Contributors

[![tzookb](https://avatars.githubusercontent.com/u/3749973?v=4)](https://github.com/tzookb "tzookb (70 commits)")[![dominservice](https://avatars.githubusercontent.com/u/13433147?v=4)](https://github.com/dominservice "dominservice (7 commits)")[![dsbilling](https://avatars.githubusercontent.com/u/9788214?v=4)](https://github.com/dsbilling "dsbilling (2 commits)")[![waffle-iron](https://avatars.githubusercontent.com/u/6912981?v=4)](https://github.com/waffle-iron "waffle-iron (1 commits)")[![IevaNavikiene](https://avatars.githubusercontent.com/u/20855363?v=4)](https://github.com/IevaNavikiene "IevaNavikiene (1 commits)")[![anatoliyarkhipov](https://avatars.githubusercontent.com/u/1934180?v=4)](https://github.com/anatoliyarkhipov "anatoliyarkhipov (1 commits)")[![Raou1d](https://avatars.githubusercontent.com/u/6343069?v=4)](https://github.com/Raou1d "Raou1d (1 commits)")

---

Tags

phplaravelmessagingchatmessage-systemlaravel-messenger

### Embed Badge

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

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

###  Alternatives

[tzookb/tbmsg

users messaging system

10717.1k](/packages/tzookb-tbmsg)[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

17878.9k](/packages/markwalet-nova-modal-response)[ecotone/laravel

Ecotone for Laravel — CQRS, Event Sourcing, Sagas, Durable Workflows, and Outbox on top of Laravel Queue, via PHP attributes.

21318.6k3](/packages/ecotone-laravel)[scriptdevelop/whatsapp-manager

Paquete para manejo de WhatsApp Business API en Laravel

783.8k](/packages/scriptdevelop-whatsapp-manager)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.4k](/packages/tomshaw-electricgrid)

PHPackages © 2026

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