marjose123/filament-webhook-server

从您的filament应用程序发送webhook

2.1.4 2024-09-22 02:17 UTC

This package is auto-updated.

Last update: 2024-09-22 02:18:29 UTC


README

Latest Version on Packagist Total Downloads

image1

本包提供Filament页面,您可以使用该页面发送webhook服务器。您可以在spatie/laravel-webhook-server上找到安装说明和完整文档。

🚨 _支持FilamentPhp v2.x的最新版本请使用此分支 1.x_或发布版本 "^1.0"._

安装

您可以通过composer安装此包

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

您可以使用以下命令发布和运行迁移

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

您可以使用以下命令发布配置文件

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

这是已发布配置文件的内容

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

将插件添加到您的面板,然后即可使用

use Marjose123\FilamentWebhookServer\WebhookPlugin;

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

使用方法

  1. 添加您希望包含在webhook中的模型
  2. 此包将自动注册Webhook-Server。您可以在访问Filament管理面板时看到它。

自定义轮询间隔

您可以通过发布配置文件并更新polling值来自定义Webhook-Server的轮询间隔。

Webhook有效负载结构

[
  {
    "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"
    }
  }
]

对于自定义选项,您需要在模型中创建toWebhookPayload方法

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

测试

composer test

变更日志

请参阅变更日志以获取有关最近更改的更多信息。

贡献

请参阅贡献指南以获取详细信息。

安全漏洞

请参阅我们的安全策略以了解如何报告安全漏洞。

致谢

许可证

MIT许可证(MIT)。请参阅许可证文件以获取更多信息。