Skip to content
Oliver Kaufmann edited this page Jan 7, 2016 · 7 revisions

##Extend Senders##

Notifynder allow to extend it's way to deliver the notifications, for example will be the case when you are repeating your self composing a simple notification or if you want automate an action before sending. Following i'll illustrate how to extend notifynder sender:

####Create Custom Sender####

For create a custom sender is easy, follow the following snippet:

use Fenos\Notifynder\Contracts\Sender;
use Fenos\Notifynder\Contracts\NotifynderSender;

class CustomSender implements Sender
{

    protected $notifications;

    public function __construct($notifications) 
    {
        $this->notifications = $notifications;
    }

    public function send(NotifynderSender $sender)
    {
        // Do your extra logic here
        return $sender->send($this->notifications);
    }
}

####Register Sender####

Now let's register it in the App\Providers\AppServiceProvider as the following:

Notifynder::extend('sendCustom', function($notifications,$app) {
    return new CustomSender($notifications);
});

####Use custom sender####

Now you are ready to send with your custom method created:

$this->notifynder->category('sayhello')
           ->from(1)
           ->to(2)
           ->url('http://localhost')
           ->extra(compact('period_day'))
           ->sendCustom();
Clone this wiki locally