Skip to content

Latest commit

 

History

History
48 lines (38 loc) · 1.13 KB

README.md

File metadata and controls

48 lines (38 loc) · 1.13 KB

Laravel Notification Channel

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';
}