<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
laravel-notification-channels / rocket-chat example snippets
// config/services.php
...
'rocketchat' => [
// Base URL for RocketChat API server (https://your.rocketchat.server.com)
'url' => env('ROCKETCHAT_URL'),
'token' => env('ROCKETCHAT_TOKEN'),
// Default channel (optional)
'channel' => env('ROCKETCHAT_CHANNEL'),
],
...
use Illuminate\Notifications\Notification;
use NotificationChannels\RocketChat\RocketChatMessage;
use NotificationChannels\RocketChat\RocketChatWebhookChannel;
class TaskCompleted extends Notification
{
public function via($notifiable): array
{
return [
RocketChatWebhookChannel::class,
];
}
public function toRocketChat($notifiable): RocketChatMessage
{
return RocketChatMessage::create('Test message')
->to('channel_name') // optional if set in config
->from('webhook_token'); // optional if set in config
}
}
public function routeNotificationForRocketChat(): string
{
return 'channel_name';
}
public function toRocketChat($notifiable)
{
return RocketChatMessage::create('Test message')
->to('channel_name') // optional if set in config
->from('webhook_token') // optional if set in config
->attachments([
RocketChatAttachment::create()->imageUrl('test'),
RocketChatAttachment::create(['image_url' => 'test']),
new RocketChatAttachment(['image_url' => 'test']),
[
'image_url' => 'test'
]
]);
}
[
[
'short' => false, // Whether this field should be a short field. Default: false
'title' => 'Title 1', //The title of this field. Required
'value' => 'Value 1' // The value of this field, displayed underneath the title value. Required
],
[
'short' => true,
'title' => 'Title 2',
'value' => 'Value 2'
],
];
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.