Skip to content

MarJose123/filament-webhook-server

Repository files navigation

Send webhooks from your filament apps

Latest Version on Packagist Total Downloads

image1

This package provides a Filament page that you can send webhook server . You'll find installation instructions and full documentation on spatie/laravel-webhook-server.


🚨 _For latest version that support FilamentPhp v2.x use this branch 1.x_or released version "^1.0"

Installation

You can install the package via composer:

composer require marjose123/filament-webhook-server:"^2.0"

You can publish and run the migrations with:

php artisan vendor:publish --tag="filament-webhook-server-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="filament-webhook-server-config"

This is the contents of the published config file:

return [
    /*
     *  Models that you want to be part of the webhooks options
     */
    'models' => [
        \App\Models\User::class,
    ],
    /*
     */
    'polling' => '10s'
];

Add the plugin to your panel and you're ready to go

use Marjose123\FilamentWebhookServer\WebhookPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        // ...
        ->plugins([
               WebhookPlugin::make() // <- Add this
        ]);  
       
}

Usage

  1. Add the models that you want to be part of the webhook
  2. This package will automatically register the Webhook-Server. You'll be able to see it when you visit your Filament admin panel.

Customising the polling interval

You can customise the polling interval for the Webhook-Server by publishing the configuration file and updating the polling value.

Webhook payload Structure

[
  {
    "event": "created",  // <== Type of Event
    "module": "Testing", // <== Module that were the event happend
    "triggered_at": "2023-01-18T05:07:37.748031Z", // <== Based on the Date and time the Event happen
    "data": { // <== Actual information depending on what you selected "Summary, All or Custom"
      "id": 34,
      "created_at": "2023-01-18T05:07:37.000000Z"
    }
  }
]

for custom option you need to create toWebhookPayload method in your models

public function toWebhookPayload()
{
    return [
        'customAttribute' => $this->yourAttribute
    ];
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.