<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
laravel-notification-channels / google-chat example snippets
class InvoicePaidNotification extends Notification
{
// Create a super simple message
public function toGoogleChat($notifiable)
{
return GoogleChatMessage::create('An invoice was paid!');
}
// ...Or you can use some simple formatting
public function toGoogleChat($notifiable)
{
return GoogleChatMessage::create()
->text('Someone just paid an invoice... ')
->bold('Woo-hoo!')
->line('Looking for ')
->link(route('invoices'), 'the details?')
->to('sales_team'); // ... and route it to specific rooms
}
// ...You can even make a fancy card!
public function toGoogleChat($notifiable)
{
return GoogleChatMessage::create()
->text('Invoice Paid! Here\'s the details:')
->card(
Card::create(
Section::create(
KeyValue::create('Amount', '$520.99', '#10004756')
->onClick(route('invoices'))
->button(TextButton::create(route('invoices'), 'View'))
)
)
)
}
}
Notification::route('googleChat', 'sales_team')->...
// Or
GoogleChatMessage::create()->to('dev_team')->...
// Or, even in your notifiable class:
public function routeNotificationForGoogleChat()
{
return 'executive';
}
Notification::route('googleChat', 'https://chat.googleapis.com/xxxxx')->...
// Or
GoogleChatMessage::create()->to('https://chat.googleapis.com/xxxxx')->...
// Or, even in your notifiable class:
public function routeNotificationForGoogleChat()
{
return 'https://chat.googleapis.com/xxxxx';
}
use NotificationChannels\GoogleChat\GoogleChatChannel;
// ...
public function via($notifiable)
{
return [
GoogleChatChannel::class
]
}
use NotificationChannels\GoogleChat\GoogleChatMessage;
public function toGoogleChat($notifiable)
{
return GoogleChatMessage::create('Hello world!');
}
use NotificationChannels\GoogleChat\GoogleChatMessage;
public function toGoogleChat($notifiable)
{
return GoogleChatMessage::create()
->bold('Heads Up!')
->line('An error was encountered whilst communicating with an external service:')
->monospaceBlock($this->errorMessage)
->italic('Want to know more? ')
->link('https://status.example.com/logs', 'Check Out the Logs.');
}
use NotificationChannels\GoogleChat\GoogleChatMessage;
use NotificationChannels\GoogleChat\Card;
use NotificationChannels\GoogleChat\Section;
use NotificationChannels\GoogleChat\Widgets\KeyValue;
use NotificationChannels\GoogleChat\Enums\Icon;
use NotificationChannels\GoogleChat\Enums\ImageStyle;
public function toGoogleChat($notifiable)
{
return GoogleChatMessage::create()
->text('An invoice was just paid... ')
->bold('Woo-hoo!')
->card(
Card::create()
->header(
'Invoice Paid',
'#1004756',
'https://cdn.example.com/avatars/xxx.png',
ImageStyle::CIRCULAR
)
->section(
Section::create(
KeyValue::create(
'Payment Received',
'$20.14',
'Paid by Josephine Smith'
)
->icon(Icon::DOLLAR)
->onClick(route('invoice.show'))
)
)
)
}