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"
];
$laravelMessaging = Ekremogul\LaravelMessaging\LaravelMessaging::create();
$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;
}
$laravelMessaging->getMessagesWithUser($user_id, $offset = 0, $take = 20);
$laravelMessaging->sendMessage($user_id, $message);
$laravelMessaging->makeSeen($message_id);
$laravelMessaging->makeSeen($message_id);
$laravelMessaging->makeSeenAll($user_id);
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.