Skip to content
This repository has been archived by the owner on Oct 22, 2019. It is now read-only.

Astrotomic/notifynder-sender-slack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Notifynder 4 Slack Sender - Laravel 5

GitHub release GitHub license GitHub issues Total Downloads

StyleCI

Code Climate

Slack Team Slack join

Documentation: Notifynder Docu


Installation

Step 1

composer require astrotomic/notifynder-sender-slack

Step 2

Add the following string to config/app.php

Providers array:

Astrotomic\Notifynder\NotifynderSenderSlackServiceProvider::class,

Step 3

Add the following array to config/notifynder.php

'senders' => [
    'slack' => [
        'webhook' => 'https://hooks.slack.com/...',
        'store' => false, // wether you want to also store the notifications in database
    ],
],

Register the sender callback in your app/Providers/AppServiceProvider.php

<?php
namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Astrotomic\Notifynder\Senders\SlackSender;
use Maknz\Slack\Message as SlackMessage;
use Fenos\Notifynder\Builder\Notification;

class AppServiceProvider extends ServiceProvider
{
    public function boot()
    {
        app('notifynder.sender')->setCallback(SlackSender::class, function (SlackMessage $message, Notification $notification) {
            // handle the message and append the from, to, icon and so on
            // https://github.com/maknz/slack#explicit-message-creation
            // you don't have to set the message text, by default (if empty) it is set in the sender itself
            // just return the message, don't send it - otherwise you will get the message two times
            return $message;
        });
    }
}