PHP code example of thibaud-dauce / laravel-notifications-mattermost
1. Go to this page and download the library: Download thibaud-dauce/laravel-notifications-mattermost 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/ */
thibaud-dauce / laravel-notifications-mattermost example snippets
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use ThibaudDauce\Mattermost\MattermostChannel;
use ThibaudDauce\Mattermost\Message as MattermostMessage;
class TicketWasOpenedByCustomer extends Notification
{
use Queueable;
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return [MattermostChannel::class];
}
/**
* Get the Mattermost representation of the notification.
*
* @param mixed $notifiable
* @return \ThibaudDauce\Mattermost\Message
*/
public function toMattermost($notifiable)
{
return (new MattermostMessage)
->username('Helpdesk')
->iconUrl(url('/images/logo_only.png'))
->text("A new ticket has been opened.")
->attachment(function ($attachment) {
$attachment->authorName($notifiable->name)
->title("[Ticket #1] Title of the ticket", '/tickets/1')
->text("Message of **the ticket**"); // Markdown supported.
});
}
}
…
/**
* Route notifications for the Mattermost channel.
*
* @return int
*/
public function routeNotificationForMattermost()
{
return $this->mattermost_webhook_url;
}
…