/**
* Route notifications for the Slack channel.
*/
public function routeNotificationForSlack(Notification $notification): string|null
{
return 'https://hooks.slack.com/services/XXXXXX';
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
*/
public function toSlack($notifiable): SlackMessage
{
$data = [
'type' => 'monitor-down',
'name' => $this->emailData['monitor_name'],
'url' => $this->emailData['monitor_url'],
'value' => 'down',
];
try {
$this->createHistoryEntry('slack', 'Monitor Down', $data, $notifiable);
} catch (\Exception $e) {
}
$monitorName = $this->emailData['monitor_name'];
$monitorURL = $this->emailData['monitor_url'];
return (new SlackMessage)
->text('One of your invoices has been paid!')
->headerBlock('Invoice Paid')
->contextBlock(function (ContextBlock $block) {
$block->text('Customer #1234');
})
->sectionBlock(function (SectionBlock $block) {
$block->text('An invoice has been paid.');
$block->field("*Invoice No:*\n1000")->markdown();
$block->field("*Invoice Recipient:*\n[email protected]")->markdown();
})
->dividerBlock()
->sectionBlock(function (SectionBlock $block) {
$block->text('Congratulations!');
});
// return (new SlackMessage)
// ->from('Domain Monitor')
// ->image('https://domain-monitor.io/slack-logo.png')
// ->error()
// ->attachment(function ($attachment) use ($monitorName, $monitorURL) {
// $attachment->title('Monitor down')
// ->content("Your monitor *$monitorName* -- _($monitorURL)_ -- has just gone *DOWN*")
// ->markdown(['text']);
// });
}
use Illuminate\Notifications\Slack\BlockKit\Blocks\ContextBlock;
use Illuminate\Notifications\Slack\BlockKit\Blocks\SectionBlock;
use Illuminate\Notifications\Slack\BlockKit\Composites\ConfirmObject;
use Illuminate\Notifications\Slack\SlackMessage;