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

ActiveLibrary

kennyuzoma/messenger
====================

Messenger functionality for Laravel 5.2.

1.2(6y ago)024MITPHPPHP &gt;=5.5.9

Since Aug 5Pushed 6y agoCompare

[ Source](https://github.com/kennyuzoma/messenger)[ Packagist](https://packagist.org/packages/kennyuzoma/messenger)[ RSS](/packages/kennyuzoma-messenger/feed)WikiDiscussions master Synced today

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

[![Build Status](https://camo.githubusercontent.com/e28c762f90410417f78863e9e105bcf364e855470edab9f77b7d96879f6a0e6f/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6765726172646f6a6261657a2f6d657373656e6765722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/gerardojbaez/messenger)[![Latest Version](https://camo.githubusercontent.com/334f30c4b62a433d75d1f245897c29ada0a986243cf9884cfb0feb359e6abba6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6765726172646f6a6261657a2f6d657373656e6765722e7376673f7374796c653d666c61742d737175617265)](https://github.com/gerardojbaez/messenger/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

Messenger
=========

[](#messenger)

Chat/Message system for Laravel 5.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 5.x
- PHP &gt;=5.5

### Composer

[](#composer)

```
$ composer require gerardojbaez/messenger

```

### Service Provider and Facade

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

> If you are using laravel 5.5 and later, you can skip the following two steps since this package supports package auto-discovery feature.

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

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

Add the Facade to your aliases array:

```
'aliases' => [

	[...]

	'Messenger' => Gerardojbaez\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="Gerardojbaez\Messenger\MessengerServiceProvider"

```

Then run migrations:

```
$ php artisan migrate

```

### Traits and Contracts

[](#traits-and-contracts)

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

See the following example:

```
