f2m2/request-notification-channel

Request Notifications driver

1.0.0 2018-03-18 13:22 UTC

This package is auto-updated.

Last update: 2024-11-11 04:03:42 UTC


README

Used to send an application/x-www-form-urlencoded POST requests.

Installation

You can install the package via composer:

composer require f2m2/request-notifcation-channel

Usage

use F2M2\RequestNotification\RequestNotificationChannel;
use F2M2\RequestNotification\RequestNotificationMessage;
use Illuminate\Notifications\Notification;

class MyNotification extends Notification
{
    public function via($notifiable)
    {
        return [RequestNotificationChannel::class];
    }

    public function toRequestNotification($notifiable)
    {
        return RequestNotificationChannel::create()
            ->data([
               'data' => [
                   'property' => 'value'
               ]
            ])
            ->userAgent("Custom-User-Agent")
            ->header('X-Custom', 'Custom-Header');
    }
}

Add the routeNotificationForRequestNotification method to your Notifiable Model, which should return the URL where the notification will call the request.

public function routeNotificationForRequestNotification()
{
    return 'http://httpbin.org/post';
}