PHPackages                             reliqarts/mardin - 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. reliqarts/mardin

AbandonedArchivedLibrary

reliqarts/mardin
================

Simplified real-time messaging for Laravel 5.

v1.0.0-rc(7y ago)132802MITPHPPHP &gt;=7.0

Since Apr 12Pushed 7y ago3 watchersCompare

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

READMEChangelogDependencies (5)Versions (8)Used By (0)

Mardin Messenger
================

[](#mardin-messenger)

Mardin is a messaging package for Laravel 5.x based on Laravel Messenger.

[![Built For Laravel](https://camo.githubusercontent.com/5eeeef36666bf2aefe6800cfd097832e37f96e2d2f2b944baf4744637b05c4c9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6275696c74253230666f722d6c61726176656c2d7265642e7376673f7374796c653d666c61742d737175617265)](http://laravel.com)[![StyleCI](https://camo.githubusercontent.com/e4a2d861a17c448dca195cc2a57060b8ec606bdfc8a0d10e99651e27357cc8af/68747470733a2f2f7374796c6563692e696f2f7265706f732f38383030383931382f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/88008918)[![Scrutinizer](https://camo.githubusercontent.com/3f275c869ad348b120fc326b11c7d2348d10faf17936d457bc68cc9c4b7c4fb1/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f72656c6971617274732f6d617264696e2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/reliqarts/mardin/)[![License](https://camo.githubusercontent.com/01773408e72900c4c8550e4a811fc1d088780b452c5473c556d262722c19290c/68747470733a2f2f706f7365722e707567782e6f72672f72656c6971617274732f6d617264696e2f6c6963656e73653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/reliqarts/mardin)[![Latest Stable Version](https://camo.githubusercontent.com/5f093efca91f3e9a2d4648c49a8145137744bdd04dca260211843dad011b2b8e/68747470733a2f2f706f7365722e707567782e6f72672f72656c6971617274732f6d617264696e2f76657273696f6e3f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/reliqarts/mardin)[![Latest Unstable Version](https://camo.githubusercontent.com/7877eb1f52be5ac2d9a77aadbdb23ac390e25b63ba3f3f699ad4a90269efeccc/68747470733a2f2f706f7365722e707567782e6f72672f72656c6971617274732f6d617264696e2f762f756e737461626c653f666f726d61743d666c61742d737175617265)](//packagist.org/packages/reliqarts/mardin)

Key Features
------------

[](#key-features)

- Integrates seemlessly with your existing application.
- Supports multi-participant conversations (threads)
- Multiple conversations per user
- View the last message for each thread available
- Easily fetch all messages in the system, all messages associated to the user, or all message associated to the user with new/unread messages
- Fetch users unread message count easily
- Very flexible usage so you can implement your own access control
- Supports real-time messaging via integration with Laravel Echo

Installation &amp; Usage
------------------------

[](#installation--usage)

### Installation

[](#installation)

Install via composer; in console:

```
composer require reliqarts/mardin

```

or require in *composer.json*:

```
{
    "require": {
        "reliqarts/mardin": "*"
    }
}
```

then run `composer update` in your terminal to pull it in.

Once this has finished, you will need to add the service provider to the providers array in your app.php config as follows:

```
ReliQArts\Mardin\MardinServiceProvider::class,
```

Publish package resources and configuration:

```
php artisan vendor:publish --provider="ReliQArts\Mardin\MardinServiceProvider"

```

You may opt to publish only configuration by using the `config` tag:

```
php artisan vendor:publish --provider="ReliQArts\Mardin\MardinServiceProvider" --tag="config"

```

Create a `users` table if you do not have one already.

**(Optional)** Define names of database tables in *laravel messenger*'s config file (config/laravel-messenger) if you don't want to use default ones:

```
'messages_table' => 'messenger_messages',
'participants_table' => 'messenger_participants',
'threads_table' => 'messenger_threads',

```

*See:* Laravel messenger [readme](https://github.com/cmgmyr/laravel-messenger/blob/master/readme.md) for more information on Laravel Messenger setup.

Run the migrations to create `messages`, `threads`, and `participant` tables.

```
php artisan migrate

```

### Configuration

[](#configuration)

- Set the message model, participant model and thread model in *laravel messenger*'s config file (config/laravel-messenger) to the provided Mardin models, or your custom models that extend these.

    e.g.

    ```
    'message_model' => ReliQArts\Mardin\Models\Message::class,

    'participant_model' => ReliQArts\Mardin\Models\Participant::class,

    'thread_model' => ReliQArts\Mardin\Models\Thread::class,

    ```
- Ensure your application is properly configured for **[broadcasting](https://laravel.com/docs/5.5/broadcasting/)**.
- Ensure your application defines the `` tag in its ``

    e.g.

    ```

    ```

    This is used alongside *mardinBase* for routing. See: [https://www.w3schools.com/tags/tag\_base.asp](https://www.w3schools.com/tags/tag_base.asp)
- Set the desired environment variables so the package knows your user model, transformer, desired views, etc.

    Example environment config:

    ```
    MARDIN_USER_MODEL="App\\User"
    MARDIN_USER_TRANSFORMER="App\\Transformers\\UserTransformer"
    MARDIN_VIEW_WRAPPER_INDEX="messages.index"
    MARDIN_VIEW_WRAPPER_SHOW="messages.show"
    ```

    These variables, and more are explained within the [config](https://github.com/ReliQArts/mardin/blob/master/config/mardin.php) file.
- Include the **mardin tray** (message notification area) somewhere within your layout to initialize mardin. The mardin tray provides initialization parameters to Mardin's JS counterpart. (without these Mardin will not be initialized)

    Example inclusion in `resources/views/layouts/app.blade.php`:

    ```
    // ...

    @include('mardin::tray', ['miId' => 'mardin-inbox-tray'])

    // ...
    ```
- #### Traits &amp; Contracts

    [](#traits--contracts)

    You must ensure that your user model and user transformer classes are properly set in your configuration (as shown above) and that they implement the `ReliQArts\Mardin\Contracts\User` and `ReliQArts\Mardin\Contracts\UserTransformer` contracts respectively.

    Your `User` model must also use the `Messagable` trait.

    e.g. User model:

    ```
    // ...
    use ReliQArts\Mardin\Traits\Messagable;
    use ReliQArts\Mardin\Contracts\User as MardinUserContract;

    class User extends Authenticatable implements MardinUserContract {
        use Messagable;

        // ...
    }
    ```

    You may also extend the Message, Participant, and Thread models. Extending the `Message` model is encouraged since you may very well wish to add a specific policy for security (via [Laravel Guard](https://laravel.com/docs/5.4/authentication)).

    e.g. Message model:

    ```
    use ReliQArts\Mardin\Models\Message as MardinMessage;

    class Message extends MardinMessage
    {
        // ...
    }
    ```

    **NB:** Remember to update *laravel messenger*'s config file (config/laravel-messenger) to reflect these.
- #### Client-side Config

    [](#client-side-config)

    Install the JS counterpart via `npm` or `yarn`:

    ```
    npm i mardin

    ```

    After adding the module via npm you may use as follows:

    ```
    // import mardin for use
    import Mardin from 'mardin';

    // initialize
    let messenger = new Mardin(app);
    ```

    *Note:* `app` above refers to an instance of your client-side application and is optional.

And... it's ready! 👌

### Usage

[](#usage)

#### Routes

[](#routes)

The following routes are made available. For clarification you may refer to the method documentations in `ReliQArts\Mardin\Http\Controllers\MessagesController` [here](https://github.com/reliqarts/mardin/blob/master/src/Http/Controllers/MessagesController.php).

```
|        | POST                           | messages                                                           | store-message                               | ReliQArts\Mardin\Http\Controllers\MessagesController@store                           | web                                                 |
|        | GET|HEAD                       | messages/c/unread                                                  | unread-messages-count                       | ReliQArts\Mardin\Http\Controllers\MessagesController@unreadCount                     | web                                                 |
|        | POST                           | messages/del                                                       | unread-message                              | ReliQArts\Mardin\Http\Controllers\MessagesController@delete                          | web                                                 |
|        | GET|HEAD                       | messages/in/{filter}.json                                          | in-threads                                  | ReliQArts\Mardin\Http\Controllers\MessagesController@inboxData                       | web                                                 |
|        | POST                           | messages/m/new                                                     | create-message                              | ReliQArts\Mardin\Http\Controllers\MessagesController@create                          | web                                                 |
|        | POST                           | messages/mr                                                        | read-message                                | ReliQArts\Mardin\Http\Controllers\MessagesController@read                            | web                                                 |
|        | POST                           | messages/mur                                                       | unread-message                              | ReliQArts\Mardin\Http\Controllers\MessagesController@unread                          | web                                                 |
|        | GET|HEAD                       | messages/t/{thread}/messages.json                                  | in-thread-messages                          | ReliQArts\Mardin\Http\Controllers\MessagesController@threadMessagesData              | web                                                 |
|        | POST                           | messages/u/{thread}                                                | update-message                              | ReliQArts\Mardin\Http\Controllers\MessagesController@update                          | web                                                 |
|        | GET|HEAD                       | messages/view/{thread}                                             | show-message                                | ReliQArts\Mardin\Http\Controllers\MessagesController@show                            | web                                                 |
|        | GET|HEAD                       | messages/{type?}                                                   | messages

```

#### Authorization

[](#authorization)

Mardin supports Laravel's default authorization model. To use the provided policy, map the policy in your `AuthServiceProvider` like so:

```
use App\Message; // a custom message model that extends ReliQArts\Mardin\Models\Message
use ReliQArts\Mardin\Policies\MessagePolicy;

/**
 * The policy mappings for the application.
 *
 * @var array
 */
protected $policies = [
    // ...
    Message::class => MessagePolicy::class,
];
```

The policy uses the `canSendMardinMessage()` and `canReceiveMardinMessage()` methods implemented on the `User` model. These methods are enforced by `ReliQArts\Mardin\Contracts\User`.

#### Sending a Message

[](#sending-a-message)

Start a new thread by making a request to `messages/m/new` (POST).

##### Sample New Message Form

[](#sample-new-message-form)

```
{!! Form::open(['route' => 'create-message']) !!}
{!! Form::hidden('subject', "New Message") !!}
{!! Form::hidden('recipients[]', $user->id) !!}

    Send Message

{!! Form::close() !!}
```

The above example uses `laravelcollective/html` to generate a HTML form which posts to the `create-message` route.

---

For more information on Laravel Messenger, check it out [here](https://github.com/cmgmyr/laravel-messenger).

🍻 cheers!

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~95 days

Recently: every ~119 days

Total

6

Last Release

2836d ago

PHP version history (2 changes)v1.0.0-betaPHP &gt;=5.6.4

v1.0.0-rcPHP &gt;=7.0

### Community

Maintainers

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

---

Top Contributors

[![reliq](https://avatars.githubusercontent.com/u/2624812?v=4)](https://github.com/reliq "reliq (38 commits)")

---

Tags

composer-packageslaravellaravel-5-packagelaravel-messengermardinmessagingmessengerpackagephpreal-timeuser

### Embed Badge

![Health badge](/badges/reliqarts-mardin/health.svg)

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

###  Alternatives

[laravel-doctrine/orm

An integration library for Laravel and Doctrine ORM

8425.3M87](/packages/laravel-doctrine-orm)[blair2004/nexopos

The Free Modern Point Of Sale System build with Laravel, TailwindCSS and Vue.js.

1.2k2.3k](/packages/blair2004-nexopos)[masterro/laravel-mail-viewer

Easily view in browser outgoing emails.

6392.1k](/packages/masterro-laravel-mail-viewer)[concrete5/core

Concrete core subtree split

19159.3k48](/packages/concrete5-core)[dragon-code/laravel-http-logger

Logging incoming HTTP requests

319.8k3](/packages/dragon-code-laravel-http-logger)

PHPackages © 2026

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