Skip to content

Super simple user 1v1 messaging system to be used within Laravel application.

License

Notifications You must be signed in to change notification settings

aurawindsurfing/messenger

Repository files navigation

Messenger for Laravel Packagist License For Laravel

Travis Status Coverage Status Scrutinizer Code Quality Github Issues

Packagist Packagist Release Packagist Downloads

This package allows you to create simple user to user messaging system within your Laravel application. It comes packaged with all the views and even a simple admin panel. It does not have support for group conversations yet as well as it does not support editing of messages. It is simply send and receive messenger.

Messenger Dashboard

Features

Easy setup & configuration.

  • One to one messaging between users
  • Multiple conversations (threads) per user
  • Returns all messages associated with the user
  • Returns the user's unread message count
  • Well documented & IDE Friendly.
  • Well tested with maximum code quality.
  • Laravel 5.7 to 5.8 are supported.
  • Made with ❤️ & ☕.

Laravel Versions

Laravel Messenger
5.7+ 1.*

Installation

You can install the package via composer:

composer require aurawindsurfing/messenger

Or place manually in composer.json:

"require": {
    "aurawindsurfing/messenger": "~1.0"
}

Run:

composer update

This package apart from standard config and migrations files includes also controller, views, factories and console commands.

To publish all assets run:

php artisan vendor:publish  --provider="Aurawindsurfing\Messenger\MessengerServiceProvider"

Create a users table if you do not have one already. If you need one, the default Laravel migration will be satisfactory.

Migrate your database:

php artisan migrate

Edit config:

config/messenger.php

This package allows you to create fake messages between users so you can construct views more easily. To view fake messages you NEED to be logged in as one of the users otherwise you will receive 404 error. To choose for which users to create messages edit your config file:

'firstUserId'  => 1,
'secondUserId' => 2,

Add the trait to your user model:

use Aurawindsurfing\Messenger\Messagable;

class User extends Authenticatable {

    use Messagable;

Usage

Populate your messenger tables with dummy data so you will be able to see some messages displayed. To do this run:

php artisan messenger:generate

Log in as one of the users designated in the config file in visit:

https://yourapp.test/messages/1

To see message threads received by first user

To clear all your dummy data run below command in your console. Be careful as this command will delete all data from messages table including real messages if they exist!

php artisan messenger:deleteAllData

Customise

Controller

(Optional) This package uses its own MessagesController which you might choose to overwrite. To do this you need to copy it from

/vendor/aurawindsurfing/messenger/src/Http/Controllers

to

/App/Http/Controllers

Edit your config file and your copied controller to amend controller namesapce:

'controller_namespace' => 'App\Http\Controllers',

This controller uses 3 methods, index, create, store feel free to rename them to whatever is necessary in your own application.

Edit your config file and amend method names:

// customise controller method names if you choose to overwrite default controller
'controller_index'  => 'index',
'controller_create' => 'create',
'controller_store'  => 'store',

Views:

php artisan vendor:publish --tag=views --provider="Aurawindsurfing\Messenger\MessengerServiceProvider"

They will be placed in:

resources/views/vendor/messenger

Migrations:

php artisan vendor:publish --tag=migrations --provider="Aurawindsurfing\Messenger\MessengerServiceProvider" 

Commands and factories:

Package factories and commands will be available for your laravel app with autoloading. You can copy them to relevant places and overwrite them if needed.

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.