PHP code example of beyondcode / slack-notification-channel
1. Go to this page and download the library: Download beyondcode/slack-notification-channel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
beyondcode / slack-notification-channel example snippets
public function routeNotificationForSlack()
{
return [
'token' => 'xoxp-slack-token',
'channel' => '#general'
];
}
public function toSlack($notifiable)
{
return (new SlackMessage)
->content('A new order has been placed');
}
public function response($response)
{
$response = $response->getBody()->getContents();
$this->order->data('slack.thread_ts', json_decode($response, true)['ts']);
}
public function toSlack($notifiable)
{
$order = $this->order;
return (new SlackMessage)
->success()
->content('Order paid')
->threadTimestamp($order->data('slack.thread_ts'))
->attachment(function ($attachment) use ($order) {
$attachment->title("Order $order->reference has been paid for.")
->content('Should now be processed.')
->action('View Order', route('orders', $order->reference));
});
}