Skip to content

ekremogul/laravel-messaging

Repository files navigation

Messaging package for Laravel

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Messaging package for Laravel

Installation

You can install the package via composer:

composer require ekremogul/laravel-messaging

You can publish and run the migrations with:

php artisan vendor:publish --tag="messaging-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="messaging-config"

This is the contents of the published config file:

return [
    "user_model" => "App\Models\User"
];

Usage

Definition

$laravelMessaging = Ekremogul\LaravelMessaging\LaravelMessaging::create();

Get Inbox

$inbox = $laravelMessaging($order = "desc", $offset = 0, $take = 20); // Retrieve the last 20 messages

foreach($inbox as $item) {
    /*
    * App\Models\User 
    * return the messaging user
    */
    $item->withUser;
    
    /*
    * Ekremogul\LaravelMessaging\Model\Message
    * return last message with user
    */ 
    $item->message;
    
    /*
    * Return 0 or 1
    * Returns 1 if there is a message you haven't read
    */
    $item->unreaded_message;
    
    /*
    * Return integer
    * Returns the total number of unread messages
    */
    $item->total_unread;
}

Recieve message with user

$laravelMessaging->getMessagesWithUser($user_id, $offset = 0, $take = 20);

Send message

$laravelMessaging->sendMessage($user_id, $message);

Make seen specific message

$laravelMessaging->makeSeen($message_id);

Make specific message seen

$laravelMessaging->makeSeen($message_id);

Make all message make with the user seen

$laravelMessaging->makeSeenAll($user_id);

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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

About

Messaging package for Laravel

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages