Don't use it on production. It's initial release. Stable version will be available at https://github.com/laravel-notification-channels/rocket-chat
This package makes it easy to send notifications using RocketChat with Laravel 5.3.
You can install the package via composer:
composer require laravel-notification-channels/rocket-chat
You must install the service provider:
// config/app.php
'providers' => [
...
NotificationChannels\RocketChat\RocketChatServiceProvider::class,
],
In order to send message to RocketChat channels, you need to obtain Webhook.
Add your RocketChat API server's base url, incoming Webhook Token and optionally the default room to your config/services.php
:
// config/services.php
...
'rocketchat' => [
// Base URL for RocketChat API server (https://your.rocketchat.server.com)
'url' => env('ROCKETCHAT_URL'),
'token' => env('ROCKETCHAT_TOKEN'),
// Default room (optional)
'room' => env('ROCKETCHAT_ROOM'),
],
...
You can use the channel in your via()
method inside the notification:
use Illuminate\Notifications\Notification;
use NotificationChannels\RocketChat\RocketChatMessage;
use NotificationChannels\RocketChat\RocketChatChannel;
class TaskCompleted extends Notification
{
public function via($notifiable)
{
return [RocketChatChannel::class];
}
public function toRocketChat($notifiable)
{
return RocketChatMessage::create("Test message")
->to('room_id') // optional if set in config
->from('webhook_token'); // optional if set in config
}
}
In order to let your notification know which RocketChat room you are targeting, add the routeNotificationForRocketChat
method to your Notifiable model:
public function routeNotificationForRocketChat()
{
return 'room_id';
}
from()
: Sets the sender's access token.
to()
: Specifies the room id to send the notification to (overridden by routeNotificationForRocketChat
if empty).
content()
: Sets a content of the notification message. Supports Github flavoured markdown.
Please see CHANGELOG for more information what has changed recently.
$ composer test
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Please see CONTRIBUTING for details.
Please see CHANGELOG for more information on what has changed recently.
The MIT License (MIT). Please see License File for more information.
CyberCog is a Social Unity of enthusiasts. Research best solutions in product & software development is our passion.