ekremogul / laravel-messaging
Messaging package for Laravel
v1.0.1
2022-10-27 11:38 UTC
Requires
- php: ^8.1
- illuminate/contracts: ^9.0
- spatie/laravel-package-tools: ^1.13.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^6.0
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpunit/phpunit: ^9.5
README
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.