Download the PHP package gerardojbaez/messenger without Composer
On this page you can find all versions of the php package gerardojbaez/messenger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gerardojbaez/messenger
More information about gerardojbaez/messenger
Files in gerardojbaez/messenger
Package messenger
Short Description Messenger functionality for Laravel 5.2.
License MIT
Informations about the package 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
Content
- Installation
- Requirements
- Composer
- Service Provider and Facade
- Config file and Migrations
- Traits and Contracts
- Usage
- Sending to One User
- Sending to Multiple Users
- Sending to thread
- Get count of new messages
- Mark thread as read
- Thread Dynamic Attributes
- Displaying user threads
- Using Models
- Config File
- License
Installation
Requirements
- Laravel 5.x
- PHP >=5.5
Composer
$ composer require gerardojbaez/messenger
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.
Add the Facade to your aliases array:
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
Add Gerardojbaez/Messenger/Traits/Messageable
trait and Gerardojbaez/Messenger/Contracts/MessageableInterface
contract to your Users
model.
See the following example:
Usage
Sending to One User
Sending to Multiple Users
Sending to Thread
Get count of new messages
Get global count - new messages in all user threads:
Get count for a particular user thread:
Mark thread as read
To mark a thread as read:
Thread Dynamic Attributes
Threads dynamic attributes are attributes that doesn't come from the database, instead we generate them based on the data.
For example, threads doesn't have a title by itself, Messenger will create it based on the participants list.
Attributes:
$thread->title
$thread->creator
to get the thread creator.$thread->lastMessage
to get the latest message in the thread.
Displaying user threads
The controller:
The view:
Preview:
Using Models
Messenger has 3 models:
You can use these as normal. For more details take a look to each model and the Gerardojbaez\Messenger\Traits\Messageable
trait.
Config File
For now you can configure what models to use.
License
This package is free software distributed under the terms of the MIT license.