8

Laravel Rocket Chat Notifications

 2 years ago
source link: https://laravel-news.com/laravel-rocket-chat-notifications
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Laravel Rocket Chat Notifications

Laravel Rocket Chat Notifications is a package that makes it easy to send notifications using RocketChat with Laravel 9+:

1use Illuminate\Notifications\Notification;
2use TeamNiftyGmbh\RocketChatNotifications\Channels\RocketChatNotificationChannel;
3use TeamNiftyGmbh\RocketChatNotifications\Messages\RocketChatMessage;
5class TaskCompleted extends Notification
7 public function via(mixed $notifiable): array
9 return [
10 RocketChatNotificationChannel::class
14 public function toRocketChat($notifiable): RocketChatMessage
16 return RocketChatMessage::create('Test Message');

The RocketChatMessage class has convenient methods to formulate your RocketChat messages. Here's an example of a few of them, including adding an attachment:

1public function toRocketChat($notifiable)
3 return RocketChatMessage::create('Test message')
4 // optional if set in config
5 ->to('channel_name')
6 // optional if set in config
7 ->from('access_token', 'rocket_chat_user_id')
8 ->attachments([
9 RocketChatAttachment::create()
10 ->imageUrl('test'),
11 RocketChatAttachment::create([
12 'image_url' => 'test'
13 ]),
14 new RocketChatAttachment(['image_url' => 'test']),
15 // Or via array
17 'image_url' => 'test'
19 ]);

For a complete list of everything, you can do to format a message, check out the available methods in the readme.

Rocket.Chat is a communication platform with private chats, team chats, etc. and includes pricing options for the SaaS product and self-managed installations. You can learn more about this package, get full installation instructions, and view the source code on GitHub.


This package was submitted to our Laravel News Links section. Links is a place the community can post packages and tutorials around the Laravel ecosystem. Follow along on Twitter @LaravelLinks


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK