Download the PHP package shahinur/messenger without Composer
On this page you can find all versions of the php package shahinur/messenger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package messenger
Messenger
This package was initially build by https://github.com/gerardojbaez/messenger 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
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 8.x
- PHP >=7.4.x
Composer
$ composer require shahinur/messenger
Service Provider and Facade
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="Shahinur\Messenger\MessengerServiceProvider"
Then run migrations:
$ php artisan migrate
Traits and Contracts
Add Shahinur/Messenger/Traits/Messageable
trait and Shahinur/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:
Using Models
Messenger has 3 models:
You can use these as normal. For more details take a look to each model and the Shahinur\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.