PHPackages                             shahinur/messenger - 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. shahinur/messenger

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

shahinur/messenger
==================

This is a messenger package for laravel 10.x. This package enables developers to add messaging funtionalities to their Laravel applications.

v2.0.0(2y ago)31841MITPHPPHP ^8.1

Since May 26Pushed 2y ago1 watchersCompare

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

READMEChangelog (2)Dependencies (3)Versions (5)Used By (0)

Messenger
=========

[](#messenger)

This package was initially build by And then the dependencies were updated

Chat/Message system for Laravel 8.x.

With Messenger:

- Users can send and receive messages.
- Users can participate in multiple conversations.
- Users can send messages to one or multiple users.

TL;DR
-----

[](#tldr)

```
use Messenger;

// Sending a message to one user:
Messenger::from($user)->to($user)->message('Hey!');

// Sending a message to multiple users: (an array of user ids)
Messenger::from($user)->to([1,2,3,4])->message('Who want to chat?!');

// Sending a message to one thread: (perfect for replying to a specific thread!)
Messenger::from($user)->to($thread)->message('I\'ll be there');
```

Content
-------

[](#content)

- [Installation](#installation)
    - [Requirements](#requirements)
    - [Composer](#composer)
    - [Service Provider and Facade](#service-provider-and-facade)
    - [Config file and Migrations](#config-file-and-migrations)
    - [Traits and Contracts](#traits-and-contracts)
- [Usage](#usage)
    - [Sending to One User](#sending-to-one-user)
    - [Sending to Multiple Users](#sending-to-multiple-users)
    - [Sending to thread](#sending-to-thread)
    - [Get count of new messages](#get-count-of-new-messages)
    - [Mark thread as read](#mark-thread-as-read)
    - [Thread Dynamic Attributes](#thread-dynamic-attributes)
    - [Displaying user threads](#displaying-user-threads)
    - [Using Models](#usgin-models)
- [Config File](#config-file)
- [License](#license)

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

[](#installation)

### Requirements

[](#requirements)

- Laravel 8.x
- PHP &gt;=7.4.x

### Composer

[](#composer)

```
$ composer require shahinur/messenger

```

### Service Provider and Facade

[](#service-provider-and-facade)

Add the package to your application service providers in `config/app.php` file.

```
'providers' => [
	/**
	 * Third Party Service Providers...
	 */
	Shahinur\Messenger\MessengerServiceProvider::class,
]
```

Add the Facade to your aliases array:

```
'aliases' => [

	[...]

	'Messenger' => Shahinur\Messenger\Facades\Messenger::class,
]
```

### Config file and Migrations

[](#config-file-and-migrations)

Publish package config file and migrations with the command:

```
$ php artisan vendor:publish --provider="Shahinur\Messenger\MessengerServiceProvider"

```

Then run migrations:

```
$ php artisan migrate

```

### Traits and Contracts

[](#traits-and-contracts)

Add `Shahinur/Messenger/Traits/Messageable` trait and `Shahinur/Messenger/Contracts/MessageableInterface` contract to your `Users` model.

See the following example:

```
