├── .art ├── filament-webhook-server1.png └── filament-webhook-server2.png ├── .prettierrc ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── composer.json ├── config └── filament-webhook-server.php ├── database ├── factories │ └── ModelFactory.php └── migrations │ ├── create_filament-webhook-server_table.php.stub │ └── create_filament_webhook_server_histories_table.php.stub ├── package.json ├── postcss.config.js ├── resources ├── css │ └── plugin.css ├── dist │ └── .gitkeep ├── js │ └── plugin.js ├── lang │ ├── en │ │ ├── .gitkeep │ │ └── default.php │ ├── pt_BR │ │ ├── .gitkeep │ │ └── default.php │ └── pt_PT │ │ ├── .gitkeep │ │ └── default.php └── views │ ├── .gitkeep │ └── pages │ ├── webhook-histories.blade.php │ └── webhooks.blade.php ├── routes └── api.php ├── src ├── ApiResponseBuilder.php ├── EventServiceProvider.php ├── FilamentWebhookServerServiceProvider.php ├── HookJobProcess.php ├── Http │ └── Controllers │ │ └── WebhookController.php ├── Listeners │ ├── WebhookFailedListener.php │ └── WebhookSuccessListener.php ├── Models │ ├── FilamentWebhookServer.php │ └── FilamentWebhookServerHistory.php ├── Observers │ └── ModelObserver.php ├── Pages │ ├── WebhookHistory.php │ └── Webhooks.php ├── Traits │ └── helper.php └── WebhookPlugin.php └── tailwind.config.js /.art/filament-webhook-server1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarJose123/filament-webhook-server/18bb4734154aae1b5190cc66a5fa92e880cb3ae2/.art/filament-webhook-server1.png -------------------------------------------------------------------------------- /.art/filament-webhook-server2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarJose123/filament-webhook-server/18bb4734154aae1b5190cc66a5fa92e880cb3ae2/.art/filament-webhook-server2.png -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": false, 3 | "singleQuote": true, 4 | "trailingComma": "all" 5 | } 6 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to `filament-webhook-server` will be documented in this file. 4 | 5 | ## 2.2.0 - 2025-03-24 6 | 7 | ### What's Changed 8 | 9 | * Support for Laravel 12 by @DALIHILLARY in https://github.com/MarJose123/filament-webhook-server/pull/41 10 | * Fix/history by @DALIHILLARY in https://github.com/MarJose123/filament-webhook-server/pull/42 11 | * Feat/navigation sort by @DALIHILLARY in https://github.com/MarJose123/filament-webhook-server/pull/43 12 | 13 | ### New Contributors 14 | 15 | * @DALIHILLARY made their first contribution in https://github.com/MarJose123/filament-webhook-server/pull/41 16 | 17 | **Full Changelog**: https://github.com/MarJose123/filament-webhook-server/compare/2.1.7...2.2.0 18 | 19 | ## 2.1.7 - 2025-03-02 20 | 21 | ### What's Changed 22 | 23 | * Bump dependabot/fetch-metadata from 2.2.0 to 2.3.0 by @dependabot in https://github.com/MarJose123/filament-webhook-server/pull/37 24 | * Add ability to add Cluster to pages by @AidanLaycock in https://github.com/MarJose123/filament-webhook-server/pull/40 25 | 26 | ### New Contributors 27 | 28 | * @AidanLaycock made their first contribution in https://github.com/MarJose123/filament-webhook-server/pull/40 29 | 30 | **Full Changelog**: https://github.com/MarJose123/filament-webhook-server/compare/2.1.6...2.1.7 31 | 32 | ## 2.1.6 - 2024-11-14 33 | 34 | ### What's Changed 35 | 36 | * Fix models register by @a21ns1g4ts in https://github.com/MarJose123/filament-webhook-server/pull/35 37 | 38 | **Full Changelog**: https://github.com/MarJose123/filament-webhook-server/compare/2.1.5...2.1.6 39 | 40 | ## 2.1.5 - 2024-11-07 41 | 42 | ### What's Changed 43 | 44 | * Secure Global Observer Registration for Models by @a21ns1g4ts in https://github.com/MarJose123/filament-webhook-server/pull/33 45 | 46 | **Full Changelog**: https://github.com/MarJose123/filament-webhook-server/compare/2.1.4...2.1.5 47 | 48 | ## 2.1.4 - 2024-09-22 49 | 50 | ### What's Changed 51 | 52 | * Add pt translations by @a21ns1g4ts in https://github.com/MarJose123/filament-webhook-server/pull/32 53 | 54 | **Full Changelog**: https://github.com/MarJose123/filament-webhook-server/compare/2.1.3...2.1.4 55 | 56 | ## 2.1.3 - 2024-07-28 57 | 58 | ### What's Changed 59 | 60 | * Bump dependabot/fetch-metadata from 2.1.0 to 2.2.0 by @dependabot in https://github.com/MarJose123/filament-webhook-server/pull/28 61 | * Remove icon composer package by @Poseidon281 in https://github.com/MarJose123/filament-webhook-server/pull/31 62 | 63 | ### New Contributors 64 | 65 | * @Poseidon281 made their first contribution in https://github.com/MarJose123/filament-webhook-server/pull/31 66 | 67 | **Full Changelog**: https://github.com/MarJose123/filament-webhook-server/compare/2.1.2...2.1.3 68 | 69 | ## 2.1.2 - 2024-06-26 70 | 71 | ### What's Changed 72 | 73 | * Update composer.json by @MarJose123 in https://github.com/MarJose123/filament-webhook-server/pull/27 74 | 75 | **Full Changelog**: https://github.com/MarJose123/filament-webhook-server/compare/2.1.1...2.1.2 76 | 77 | ## 2.1.1 - 2024-05-22 78 | 79 | ### What's Changed 80 | 81 | * Add webhook api feature by @0xCyyy3000 in https://github.com/MarJose123/filament-webhook-server/pull/26 82 | 83 | **Full Changelog**: https://github.com/MarJose123/filament-webhook-server/compare/2.1.0...2.1.1 84 | 85 | ## 2.1.0 - 2024-05-22 86 | 87 | ### What's Changed 88 | 89 | * Support multilevel models by @0xCyyy3000 in https://github.com/MarJose123/filament-webhook-server/pull/25 90 | * Laravel 11 Compatibility by @0xCyyy3000 in https://github.com/MarJose123/filament-webhook-server/pull/24 91 | * Bump dependabot/fetch-metadata from 1.6.0 to 2.1.0 by @dependabot in https://github.com/MarJose123/filament-webhook-server/pull/23 92 | 93 | ### New Contributors 94 | 95 | * @0xCyyy3000 made their first contribution in https://github.com/MarJose123/filament-webhook-server/pull/25 96 | 97 | **Full Changelog**: https://github.com/MarJose123/filament-webhook-server/compare/2.0.1...2.1.0 98 | 99 | ## 2.0.1 - 2024-02-21 100 | 101 | ### What's Changed 102 | 103 | * Bump stefanzweifel/git-auto-commit-action from 4 to 5 by @dependabot in https://github.com/MarJose123/filament-webhook-server/pull/17 104 | * Bump actions/dependency-review-action from 3 to 4 by @dependabot in https://github.com/MarJose123/filament-webhook-server/pull/18 105 | * Added boolean cast for verifySsl by @soixt in https://github.com/MarJose123/filament-webhook-server/pull/21 106 | 107 | ### New Contributors 108 | 109 | * @soixt made their first contribution in https://github.com/MarJose123/filament-webhook-server/pull/21 110 | 111 | **Full Changelog**: https://github.com/MarJose123/filament-webhook-server/compare/2.0.0...2.0.1 112 | 113 | ## 2.0.0 - Support Filament v3 - 2023-09-22 114 | 115 | ### What's Changed 116 | 117 | - Bump actions/checkout from 3 to 4 by @dependabot in https://github.com/MarJose123/filament-webhook-server/pull/13 118 | 119 | **Full Changelog**: https://github.com/MarJose123/filament-webhook-server/compare/1.2.2...2.0.0 120 | 121 | ## 1.2.2 - 2023-07-06 122 | 123 | ### What's Changed 124 | 125 | - Bump dependabot/fetch-metadata from 1.5.1 to 1.6.0 by @dependabot in https://github.com/MarJose123/filament-webhook-server/pull/11 126 | - Update WebhookHistory.php by @MarJose123 in https://github.com/MarJose123/filament-webhook-server/pull/12 127 | 128 | **Full Changelog**: https://github.com/MarJose123/filament-webhook-server/compare/1.2.1...1.2.2 129 | 130 | ## 1.2.1 - 2023-06-11 131 | 132 | ### What's Changed 133 | 134 | - Bump dependabot/fetch-metadata from 1.3.6 to 1.4.0 by @dependabot in https://github.com/MarJose123/filament-webhook-server/pull/7 135 | - Bump dependabot/fetch-metadata from 1.4.0 to 1.5.1 by @dependabot in https://github.com/MarJose123/filament-webhook-server/pull/8 136 | - Add pages configurable by @a21ns1g4ts in https://github.com/MarJose123/filament-webhook-server/pull/9 137 | 138 | ### New Contributors 139 | 140 | - @a21ns1g4ts made their first contribution in https://github.com/MarJose123/filament-webhook-server/pull/9 141 | 142 | **Full Changelog**: https://github.com/MarJose123/filament-webhook-server/compare/1.2.0...1.2.1 143 | 144 | ## 1.2.0 - 2023-04-14 145 | 146 | ### What's Changed 147 | 148 | - feat: add custom webhook payload and support to Laravel 10 by @jeffersonGlemos in https://github.com/MarJose123/filament-webhook-server/pull/6 149 | 150 | ### New Contributors 151 | 152 | - @jeffersonGlemos made their first contribution in https://github.com/MarJose123/filament-webhook-server/pull/6 153 | 154 | **Full Changelog**: https://github.com/MarJose123/filament-webhook-server/compare/1.1.0...1.2.0 155 | 156 | ## 1.1.0 - 2023-02-13 157 | 158 | ### Reminder 159 | 160 | - Update your Config file to this latest 161 | 162 | ```php 163 | 164 | return [ 165 | /* 166 | * Models that you want to be part of the webhooks options 167 | */ 168 | 'models' => [ 169 | \App\Models\User::class, 170 | ], 171 | /* 172 | */ 173 | 'polling' => '10s', 174 | 'webhook' => [ 175 | 'keep_history' => false, 176 | ], 177 | ]; 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | ``` 194 | - Republish and run the migrations with: 195 | 196 | ```bash 197 | php artisan vendor:publish --tag="filament-webhook-server-migrations" 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | ``` 214 | ```bash 215 | php artisan migrate 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | ``` 232 | to be able to add the new table 233 | 234 | ### What's Changed 235 | 236 | - Bump actions/dependency-review-action from 2 to 3 by @dependabot in https://github.com/MarJose123/filament-webhook-server/pull/2 237 | - Bump dependabot/fetch-metadata from 1.3.5 to 1.3.6 by @dependabot in https://github.com/MarJose123/filament-webhook-server/pull/3 238 | - Feat history log by @MarJose123 in https://github.com/MarJose123/filament-webhook-server/pull/4 239 | 240 | ### New Contributors 241 | 242 | - @dependabot made their first contribution in https://github.com/MarJose123/filament-webhook-server/pull/2 243 | 244 | **Full Changelog**: https://github.com/MarJose123/filament-webhook-server/compare/1.0.1...1.1.0 245 | 246 | ## 1.0.1 247 | 248 | ## What's Changed 249 | 250 | - dynamic carbon timezone and added updated_at on payload for summary by @MarJose123 in https://github.com/MarJose123/filament-webhook-server/pull/1 251 | 252 | ## New Contributors 253 | 254 | - @MarJose123 made their first contribution in https://github.com/MarJose123/filament-webhook-server/pull/1 255 | 256 | **Full Changelog**: https://github.com/MarJose123/filament-webhook-server/compare/1.0.0...1.0.1 257 | 258 | ## 1.0.0 259 | 260 | - initial release 261 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) marjose123 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Send webhooks from your filament apps 2 | 3 | [![Latest Version on Packagist](https://img.shields.io/packagist/v/marjose123/filament-webhook-server.svg?style=flat-square)](https://packagist.org/packages/marjose123/filament-webhook-server) 4 | [![Total Downloads](https://img.shields.io/packagist/dt/marjose123/filament-webhook-server.svg?style=flat-square)](https://packagist.org/packages/marjose123/filament-webhook-server) 5 | 6 | ![image1](https://github.com/MarJose123/filament-webhook-server/blob/2.x/.art/filament-webhook-server1.png) 7 | 8 | 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](https://github.com/spatie/laravel-webhook-server). 9 | 10 | --- 11 | :rotating_light: _For latest version that support FilamentPhp v2.x use this branch [1.x](https://github.com/MarJose123/filament-webhook-server/tree/1.x)_or released version "^1.0" 12 | 13 | ## Installation 14 | 15 | You can install the package via composer: 16 | 17 | ```bash 18 | composer require marjose123/filament-webhook-server:"^2.0" 19 | ``` 20 | 21 | You can publish and run the migrations with: 22 | 23 | ```bash 24 | php artisan vendor:publish --tag="filament-webhook-server-migrations" 25 | php artisan migrate 26 | ``` 27 | 28 | You can publish the config file with: 29 | 30 | ```bash 31 | php artisan vendor:publish --tag="filament-webhook-server-config" 32 | ``` 33 | 34 | This is the contents of the published config file: 35 | 36 | ```php 37 | return [ 38 | /* 39 | * Models that you want to be part of the webhooks options 40 | */ 41 | 'models' => [ 42 | \App\Models\User::class, 43 | ], 44 | /* 45 | */ 46 | 'polling' => '10s' 47 | ]; 48 | 49 | ``` 50 | 51 | Add the plugin to your panel and you're ready to go 52 | ```php 53 | 54 | use Marjose123\FilamentWebhookServer\WebhookPlugin; 55 | 56 | public function panel(Panel $panel): Panel 57 | { 58 | return $panel 59 | // ... 60 | ->plugins([ 61 | WebhookPlugin::make() // <- Add this 62 | ]); 63 | 64 | } 65 | 66 | ``` 67 | 68 | 69 | ## Usage 70 | > 1. Add the models that you want to be part of the webhook 71 | > 2. This package will automatically register the `Webhook-Server`. You'll be able to see it when you visit your Filament admin panel. 72 | 73 | ## Customising the polling interval 74 | 75 | You can customise the polling interval for the `Webhook-Server` by publishing the configuration file and updating the `polling` value. 76 | 77 | ## Webhook payload Structure 78 | ``` 79 | [ 80 | { 81 | "event": "created", // <== Type of Event 82 | "module": "Testing", // <== Module that were the event happend 83 | "triggered_at": "2023-01-18T05:07:37.748031Z", // <== Based on the Date and time the Event happen 84 | "data": { // <== Actual information depending on what you selected "Summary, All or Custom" 85 | "id": 34, 86 | "created_at": "2023-01-18T05:07:37.000000Z" 87 | } 88 | } 89 | ] 90 | ``` 91 | for custom option you need to create toWebhookPayload method in your models 92 | 93 | ``` 94 | public function toWebhookPayload() 95 | { 96 | return [ 97 | 'customAttribute' => $this->yourAttribute 98 | ]; 99 | } 100 | ``` 101 | 102 | ## Testing 103 | 104 | ```bash 105 | composer test 106 | ``` 107 | 108 | ## Changelog 109 | 110 | Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. 111 | 112 | ## Contributing 113 | 114 | Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details. 115 | 116 | ## Security Vulnerabilities 117 | 118 | Please review [our security policy](../../security/policy) on how to report security vulnerabilities. 119 | 120 | ## Credits 121 | 122 | - [Marjose](https://github.com/MarJose123) 123 | - [All Contributors](../../contributors) 124 | 125 | ## License 126 | 127 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 128 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "marjose123/filament-webhook-server", 3 | "description": "Send webhooks from your filament apps", 4 | "keywords": [ 5 | "marjose123", 6 | "laravel", 7 | "filament-webhook-server" 8 | ], 9 | "homepage": "https://github.com/marjose123/filament-webhook-server", 10 | "license": "MIT", 11 | "authors": [ 12 | { 13 | "name": "Marjose", 14 | "email": "hypernate1@gmail.com", 15 | "role": "Developer" 16 | } 17 | ], 18 | "require": { 19 | "php": "^8.0 || ^8.1 || ^8.2", 20 | "filament/filament": "^3.0", 21 | "illuminate/contracts": "^9.0 || ^10.0 || ^11.0 || ^12.0", 22 | "spatie/laravel-model-info": "^1.4 || ^2.0", 23 | "spatie/laravel-package-tools": "^1.13.5", 24 | "spatie/laravel-webhook-server": "^3.4" 25 | }, 26 | "require-dev": { 27 | "friendsofphp/php-cs-fixer": "^3.13", 28 | "laravel/pint": "^1.4", 29 | "nunomaduro/collision": "^6.0 || ^7.0", 30 | "orchestra/testbench": "^7.0 || ^9.0", 31 | "pestphp/pest": "^1.22", 32 | "pestphp/pest-plugin-laravel": "^1.1", 33 | "pestphp/pest-plugin-livewire": "^1.0", 34 | "pestphp/pest-plugin-parallel": "^0.3", 35 | "phpmd/phpmd": "^2.13", 36 | "phpunit/phpunit": "^9.5 || ^10.0 || ^10.5", 37 | "spatie/laravel-ray": "^1.26", 38 | "squizlabs/php_codesniffer": "^3.7" 39 | }, 40 | "autoload": { 41 | "psr-4": { 42 | "Marjose123\\FilamentWebhookServer\\": "src", 43 | "Marjose123\\FilamentWebhookServer\\Database\\Factories\\": "database/factories" 44 | }, 45 | "files": [ 46 | "src/Traits/helper.php" 47 | ] 48 | }, 49 | "autoload-dev": { 50 | "psr-4": { 51 | "Marjose123\\FilamentWebhookServer\\Tests\\": "tests" 52 | } 53 | }, 54 | "scripts": { 55 | "test:pest": "vendor/bin/pest --parallel", 56 | "format": "./vendor/bin/pint", 57 | "test": [ 58 | "@test:pest", 59 | "@test:phpstan" 60 | ] 61 | }, 62 | "config": { 63 | "sort-packages": true, 64 | "allow-plugins": { 65 | "composer/package-versions-deprecated": true, 66 | "pestphp/pest-plugin": true, 67 | "phpstan/extension-installer": true 68 | } 69 | }, 70 | "extra": { 71 | "laravel": { 72 | "providers": [ 73 | "Marjose123\\FilamentWebhookServer\\FilamentWebhookServerServiceProvider" 74 | ], 75 | "aliases": { 76 | "FilamentWebhookServer": "Marjose123\\FilamentWebhookServer\\Facades\\FilamentWebhookServer" 77 | } 78 | } 79 | }, 80 | "minimum-stability": "dev", 81 | "prefer-stable": true 82 | } 83 | -------------------------------------------------------------------------------- /config/filament-webhook-server.php: -------------------------------------------------------------------------------- 1 | [ 11 | \App\Models\User::class, 12 | ], 13 | /* 14 | */ 15 | 'polling' => '10s', 16 | 'webhook' => [ 17 | 'keep_history' => false, 18 | ], 19 | /* 20 | * Use to put pages within Clusters 21 | */ 22 | 'cluster' => null, 23 | 'pages' => [ 24 | Webhooks::class, 25 | WebhookHistory::class, 26 | ], 27 | 'navigation' => [ 28 | 'icon' => 'heroicon-s-arrow-up-on-square-stack', 29 | 'sort' => 0, 30 | ] 31 | ]; 32 | -------------------------------------------------------------------------------- /database/factories/ModelFactory.php: -------------------------------------------------------------------------------- 1 | id(); 13 | $table->string('name'); 14 | $table->longText('description'); 15 | $table->string('url'); 16 | $table->string('method'); 17 | $table->string('model'); 18 | $table->json('header')->nullable(); 19 | $table->string('data_option'); 20 | $table->boolean('verifySsl'); 21 | $table->string('status')->nullable(); 22 | $table->json('events')->nullable(); 23 | $table->timestamps(); 24 | }); 25 | } 26 | 27 | public function down() 28 | { 29 | Schema::dropIfExists('filament_webhook_servers'); 30 | } 31 | }; 32 | -------------------------------------------------------------------------------- /database/migrations/create_filament_webhook_server_histories_table.php.stub: -------------------------------------------------------------------------------- 1 | id(); 12 | $table->foreignId('webhook_client')->nullable(); 13 | $table->uuid('uuid'); 14 | $table->string('status_code')->nullable(); 15 | $table->text('errorMessage')->nullable(); 16 | $table->string('errorType')->nullable(); 17 | $table->integer('attempt')->nullable(); 18 | $table->timestamps(); 19 | }); 20 | } 21 | 22 | public function down() 23 | { 24 | Schema::dropIfExists('filament_webhook_server_histories'); 25 | } 26 | }; 27 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "dev:styles": "npx tailwindcss -i resources/css/plugin.css -o resources/dist/filament-webhook-server.css --postcss --watch", 5 | "dev:scripts": "esbuild resources/js/plugin.js --bundle --sourcemap=inline --outfile=resources/dist/filament-webhook-server.js --watch", 6 | "build:styles": "npx tailwindcss -i resources/css/plugin.css -o resources/dist/filament-webhook-server.css --postcss --minify && npm run purge", 7 | "build:scripts": "esbuild resources/js/plugin.js --bundle --minify --outfile=resources/dist/filament-webhook-server.js", 8 | "purge": "filament-purge -i resources/dist/filament-webhook-server.css -o resources/dist/filament-webhook-server.css", 9 | "dev": "npm-run-all --parallel dev:*", 10 | "build": "npm-run-all build:*" 11 | }, 12 | "devDependencies": { 13 | "@awcodes/filament-plugin-purge": "^1.0.2", 14 | "autoprefixer": "^10.4.7", 15 | "esbuild": "^0.8.57", 16 | "npm-run-all": "^4.1.5", 17 | "postcss": "^8.4.14", 18 | "prettier": "^2.7.1", 19 | "prettier-plugin-tailwindcss": "^0.1.13", 20 | "tailwindcss": "^3.1.6" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /resources/css/plugin.css: -------------------------------------------------------------------------------- 1 | @tailwind utilities; 2 | -------------------------------------------------------------------------------- /resources/dist/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarJose123/filament-webhook-server/18bb4734154aae1b5190cc66a5fa92e880cb3ae2/resources/dist/.gitkeep -------------------------------------------------------------------------------- /resources/js/plugin.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarJose123/filament-webhook-server/18bb4734154aae1b5190cc66a5fa92e880cb3ae2/resources/js/plugin.js -------------------------------------------------------------------------------- /resources/lang/en/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarJose123/filament-webhook-server/18bb4734154aae1b5190cc66a5fa92e880cb3ae2/resources/lang/en/.gitkeep -------------------------------------------------------------------------------- /resources/lang/en/default.php: -------------------------------------------------------------------------------- 1 | [ 5 | 'heading' => 'Webhook', 6 | 'navigation' => [ 7 | 'label' => 'Webhook', 8 | 'group' => 'Developer', 9 | ], 10 | 'button' => [ 11 | 'add_new_webhook' => 'Add New Webhook', 12 | ], 13 | 'modal' => [ 14 | 'label' => 'Add New Webhook', 15 | 'button' => [ 16 | 'create' => 'Create', 17 | ], 18 | ], 19 | 'history' => [ 20 | 'heading' => 'Webhook Transaction Logs', 21 | 'back' => 'Go Back', 22 | ], 23 | ], 24 | 'notification' => [ 25 | 'create' => [ 26 | 'success' => 'New Webhook successfully created!', 27 | ], 28 | ], 29 | 30 | ]; 31 | -------------------------------------------------------------------------------- /resources/lang/pt_BR/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarJose123/filament-webhook-server/18bb4734154aae1b5190cc66a5fa92e880cb3ae2/resources/lang/pt_BR/.gitkeep -------------------------------------------------------------------------------- /resources/lang/pt_BR/default.php: -------------------------------------------------------------------------------- 1 | [ 5 | 'heading' => 'Webhook', 6 | 'navigation' => [ 7 | 'label' => 'Webhook', 8 | 'group' => 'Desenvolvedor', 9 | ], 10 | 'button' => [ 11 | 'add_new_webhook' => 'Adicionar Novo Webhook', 12 | ], 13 | 'modal' => [ 14 | 'label' => 'Adicionar Novo Webhook', 15 | 'button' => [ 16 | 'create' => 'Criar', 17 | ], 18 | ], 19 | 'history' => [ 20 | 'heading' => 'Registros de Transações de Webhook', 21 | 'back' => 'Voltar', 22 | ], 23 | ], 24 | 'notification' => [ 25 | 'create' => [ 26 | 'success' => 'Novo Webhook criado com sucesso!', 27 | ], 28 | ], 29 | ]; 30 | -------------------------------------------------------------------------------- /resources/lang/pt_PT/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarJose123/filament-webhook-server/18bb4734154aae1b5190cc66a5fa92e880cb3ae2/resources/lang/pt_PT/.gitkeep -------------------------------------------------------------------------------- /resources/lang/pt_PT/default.php: -------------------------------------------------------------------------------- 1 | [ 5 | 'heading' => 'Webhook', 6 | 'navigation' => [ 7 | 'label' => 'Webhook', 8 | 'group' => 'Desenvolvedor', 9 | ], 10 | 'button' => [ 11 | 'add_new_webhook' => 'Adicionar Novo Webhook', 12 | ], 13 | 'modal' => [ 14 | 'label' => 'Adicionar Novo Webhook', 15 | 'button' => [ 16 | 'create' => 'Criar', 17 | ], 18 | ], 19 | 'history' => [ 20 | 'heading' => 'Registos de Transações de Webhook', 21 | 'back' => 'Voltar', 22 | ], 23 | ], 24 | 'notification' => [ 25 | 'create' => [ 26 | 'success' => 'Novo Webhook criado com sucesso!', 27 | ], 28 | ], 29 | ]; 30 | -------------------------------------------------------------------------------- /resources/views/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarJose123/filament-webhook-server/18bb4734154aae1b5190cc66a5fa92e880cb3ae2/resources/views/.gitkeep -------------------------------------------------------------------------------- /resources/views/pages/webhook-histories.blade.php: -------------------------------------------------------------------------------- 1 | 2 |
3 | {{ $this->table }} 4 |
5 |
6 | -------------------------------------------------------------------------------- /resources/views/pages/webhooks.blade.php: -------------------------------------------------------------------------------- 1 | 2 |
3 | {{ $this->table }} 4 |
5 | 6 | 7 |

{{ __('filament-webhook-server::default.pages.modal.label') }}

8 |
9 | 10 | {{$this->form}} 11 | 12 | 13 | 14 | {{ __('filament-webhook-server::default.pages.modal.button.create') }} 15 | 16 | 17 |
18 |
19 | -------------------------------------------------------------------------------- /routes/api.php: -------------------------------------------------------------------------------- 1 | group(function () { 7 | Route::get('/', [WebhookController::class, 'get']); 8 | Route::post('/', [WebhookController::class, 'create']); 9 | Route::patch('/{id}', [WebhookController::class, 'update']); 10 | Route::delete('/{id}', [WebhookController::class, 'delete']); 11 | }); 12 | -------------------------------------------------------------------------------- /src/ApiResponseBuilder.php: -------------------------------------------------------------------------------- 1 | setMessage(null); 24 | } 25 | 26 | public function setModel(Model $model): static 27 | { 28 | $this->model = $model; 29 | 30 | return $this; 31 | } 32 | 33 | public function setModule($module): static 34 | { 35 | $this->module = $module; 36 | 37 | return $this; 38 | } 39 | 40 | public function setEvent($event): static 41 | { 42 | $this->event = $event; 43 | 44 | return $this; 45 | } 46 | 47 | public function setMessage(?string $message): static 48 | { 49 | $this->message = $message; 50 | 51 | return $this; 52 | } 53 | 54 | public function setDataOption(string $dataOption): static 55 | { 56 | $this->dataOption = $dataOption; 57 | 58 | return $this; 59 | } 60 | 61 | public function generate() 62 | { 63 | $payload = match ($this->dataOption) { 64 | 'summary' => [ 65 | 'id' => $this->model->id ?? $this->model->uuid ?? null, 66 | 'created_at' => $this->model->created_at ?? Carbon::now()->timezone(config('app.timezone')), 67 | 'updated_at' => $this->model->updated_at ?? null, 68 | ], 69 | 'all' => (object)$this->model->attributesToArray(), 70 | 'custom' => method_exists($this->model, 'toWebhookPayload') 71 | ? (object)$this->model->toWebhookPayload() : [], 72 | default => [], 73 | }; 74 | $apiReponse = [ 75 | 'event' => $this->event ?? null, 76 | 'module' => $this->module, 77 | 'triggered_at' => Carbon::now()->timezone(config('app.timezone')), 78 | 'data' => $payload, 79 | ]; 80 | 81 | return (object)$apiReponse; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/EventServiceProvider.php: -------------------------------------------------------------------------------- 1 | [ 15 | WebhookSuccessListener::class, 16 | ], 17 | FinalWebhookCallFailedEvent::class => [ 18 | WebhookFailedListener::class, 19 | ], 20 | ]; 21 | 22 | /** 23 | * Register any events for your application. 24 | * 25 | * @return void 26 | */ 27 | public function boot() 28 | { 29 | parent::boot(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/FilamentWebhookServerServiceProvider.php: -------------------------------------------------------------------------------- 1 | name(static::$name) 23 | ->hasConfigFile() 24 | ->hasTranslations() 25 | ->hasMigrations(['create_filament-webhook-server_table', 'create_filament_webhook_server_histories_table']) 26 | ->hasViews(); 27 | } 28 | 29 | 30 | /** 31 | * @throws InvalidPackage 32 | */ 33 | public function register(): void 34 | { 35 | parent::register(); 36 | $this->app->register(EventServiceProvider::class); 37 | } 38 | 39 | public function boot(): void 40 | { 41 | parent::boot(); 42 | self::registerGlobalObserver(); 43 | } 44 | 45 | private static function registerGlobalObserver(): void 46 | { 47 | /** @var array|string[] $MODELS */ 48 | $MODELS = config('filament-webhook-server.models', []); 49 | 50 | foreach ($MODELS as $model) { 51 | if (class_exists($model)) { 52 | $model::observe(ModelObserver::class); 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/HookJobProcess.php: -------------------------------------------------------------------------------- 1 | model = $model; 25 | $this->search = $search; 26 | $this->event = $event; 27 | $this->module = $module; 28 | } 29 | 30 | public function send(): void 31 | { 32 | foreach ($this->search as $webhookClient) { 33 | WebhookCall::create() 34 | ->url($webhookClient->url) 35 | ->maximumTries(3) 36 | ->meta(['webhookClient' => $webhookClient->id]) 37 | ->doNotSign() 38 | ->useHttpVerb($webhookClient->method) 39 | ->verifySsl($webhookClient->verifySsl) 40 | ->withHeaders($webhookClient->header) 41 | ->payload([$this->payload($this->model, $this->event, $this->module,$webhookClient->data_option)]) 42 | ->dispatchSync(); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Http/Controllers/WebhookController.php: -------------------------------------------------------------------------------- 1 | validate([ 15 | 'name' => ['required', 'string'], 16 | 'description' => ['required', 'string'], 17 | 'url' => ['required', 'string'], 18 | 'method' => ['required', 'string', 'in:get,post'], 19 | 'model' => ['required', 'string'], 20 | 'header' => ['sometimes', 'required', 'string'], 21 | 'data_option' => ['required', 'string', 'in:all,summary,custom'], 22 | 'verifySsl' => ['required', 'boolean'], 23 | 'events' => ['required', 'array'], 24 | 'events.*' => ['required', 'string', 'min:1', 'in:created,updated,deleted,restored,forceDeleted'], 25 | ]); 26 | 27 | try { 28 | $webhook = FilamentWebhookServer::create($request->all()); 29 | return response()->json([ 30 | 'message' => 'Webhook created!', 31 | 'webhook_id' => $webhook->id, 32 | ], ResponseAlias::HTTP_CREATED); 33 | } catch (\Throwable $th) { 34 | return response()->json([ 35 | 'error' => [ 36 | 'message' => $th->getMessage() 37 | ] 38 | ], ResponseAlias::HTTP_INTERNAL_SERVER_ERROR); 39 | } 40 | } 41 | 42 | public function get() 43 | { 44 | try { 45 | return response()->json( 46 | FilamentWebhookServer::all(), 47 | ResponseAlias::HTTP_OK 48 | ); 49 | } catch (\Throwable $th) { 50 | return response()->json([ 51 | 'error' => [ 52 | 'message' => $th->getMessage() 53 | ] 54 | ], ResponseAlias::HTTP_INTERNAL_SERVER_ERROR); 55 | } 56 | } 57 | 58 | public function update(Request $request, $id) 59 | { 60 | try { 61 | $request->validate([ 62 | 'name' => ['sometimes', 'required', 'string'], 63 | 'description' => ['sometimes', 'required', 'string'], 64 | 'url' => ['sometimes', 'required', 'string'], 65 | 'method' => ['sometimes', 'required', 'string', 'in:get,post'], 66 | 'model' => ['sometimes', 'required', 'string'], 67 | 'header' => ['sometimes', 'required', 'string'], 68 | 'data_option' => ['sometimes', 'required', 'string', 'in:all,summary,custom'], 69 | 'verifySsl' => ['sometimes', 'required', 'boolean'], 70 | 'events' => ['sometimes', 'required', 'array'], 71 | 'events.*' => ['sometimes', 'required', 'string', 'min:1', 'in:created,updated,deleted,restored,forceDeleted'], 72 | ]); 73 | 74 | $webhook = FilamentWebhookServer::findOrFail($id); 75 | $webhook->update($request->all()); 76 | 77 | return response()->json(['message' => 'Webhook updated!'],ResponseAlias::HTTP_OK); 78 | } catch (\Throwable $th) { 79 | return response()->json([ 80 | 'error' => [ 81 | 'message' => $th->getMessage() 82 | ] 83 | ], ResponseAlias::HTTP_INTERNAL_SERVER_ERROR); 84 | } 85 | } 86 | 87 | public function delete($id) 88 | { 89 | try { 90 | $webhook = FilamentWebhookServer::findOrFail($id); 91 | $webhook->delete(); 92 | 93 | return response()->json(['message' => 'Webhook deleted!'], ResponseAlias::HTTP_OK); 94 | } catch (\Throwable $th) { 95 | return response()->json([ 96 | 'error' => [ 97 | 'message' => $th->getMessage() 98 | ] 99 | ], ResponseAlias::HTTP_INTERNAL_SERVER_ERROR); 100 | } 101 | } 102 | } 103 | 104 | -------------------------------------------------------------------------------- /src/Listeners/WebhookFailedListener.php: -------------------------------------------------------------------------------- 1 | webhook_client = $event->meta['webhookClient']; 21 | $webhookClientHistory->uuid = $event->uuid; 22 | $webhookClientHistory->status_code = $event->response->getStatusCode(); 23 | $webhookClientHistory->errorMessage = $event->response->getReasonPhrase(); 24 | $webhookClientHistory->errorType = $event->errorType; 25 | $webhookClientHistory->attempt = $event->attempt; 26 | $res = $webhookClientHistory->save(); 27 | } catch (\Exception $error) { 28 | Log::info(print_r($error, true)); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Listeners/WebhookSuccessListener.php: -------------------------------------------------------------------------------- 1 | webhook_client = $event->meta['webhookClient']; 21 | $webhookClientHistory->uuid = $event->uuid; 22 | $webhookClientHistory->status_code = $event->response->getStatusCode(); 23 | $webhookClientHistory->errorMessage = ''; 24 | $webhookClientHistory->errorType = ''; 25 | $webhookClientHistory->attempt = $event->attempt; 26 | $res = $webhookClientHistory->save(); 27 | } catch (\Exception $error) { 28 | Log::info(print_r($error, true)); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Models/FilamentWebhookServer.php: -------------------------------------------------------------------------------- 1 | 'array', 24 | 'events' => 'array', 25 | 'verifySsl' => 'boolean', 26 | ]; 27 | 28 | public function transactionlogs() 29 | { 30 | return $this->hasMany(FilamentWebhookServerHistory::class, 'webhook_client', 'id'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Models/FilamentWebhookServerHistory.php: -------------------------------------------------------------------------------- 1 | getShortName()); 16 | /* 17 | * Search on the DB that want to receive webhook from this model 18 | */ 19 | $search = FilamentWebhookServer::query()->whereJsonContains('events', ['created'])->where('model', '=', $module)->get(); 20 | /* 21 | * Send to Job Process 22 | */ 23 | (new HookJobProcess($search, $model, 'created', $module))->send(); 24 | } 25 | 26 | public function updated(Model $model) 27 | { 28 | $modelInfo = ModelInfo::forModel($model::class); 29 | $module = ucfirst(str_replace("App\Models\\", '', $modelInfo->class)); 30 | /* 31 | * Search on the DB that want to receive webhook from this model 32 | */ 33 | $search = FilamentWebhookServer::query()->whereJsonContains('events', ['updated'])->where('model', '=', $module)->get(); 34 | /* 35 | * Send to Job Process 36 | */ 37 | (new HookJobProcess($search, $model, 'updated', $module))->send(); 38 | } 39 | 40 | public function deleted(Model $model) 41 | { 42 | $modelInfo = ModelInfo::forModel($model::class); 43 | $module = ucfirst(str_replace("App\Models\\", '', $modelInfo->class)); 44 | /* 45 | * Search on the DB that want to receive webhook from this model 46 | */ 47 | $search = FilamentWebhookServer::query()->whereJsonContains('events', ['deleted'])->where('model', '=', $module)->get(); 48 | /* 49 | * Send to Job Process 50 | */ 51 | (new HookJobProcess($search, $model, 'deleted', $module))->send(); 52 | } 53 | 54 | public function restored(Model $model) 55 | { 56 | $modelInfo = ModelInfo::forModel($model::class); 57 | $module = ucfirst(str_replace("App\Models\\", '', $modelInfo->class)); 58 | /* 59 | * Search on the DB that want to receive webhook from this model 60 | */ 61 | $search = FilamentWebhookServer::query()->whereJsonContains('events', ['restored'])->where('model', '=', $module)->get(); 62 | /* 63 | * Send to Job Process 64 | */ 65 | (new HookJobProcess($search, $model, 'restored', $module))->send(); 66 | } 67 | 68 | public function forceDeleted(Model $model) 69 | { 70 | $modelInfo = ModelInfo::forModel($model::class); 71 | $module = ucfirst(str_replace("App\Models\\", '', $modelInfo->class)); 72 | /* 73 | * Search on the DB that want to receive webhook from this model 74 | */ 75 | $search = FilamentWebhookServer::query()->whereJsonContains('events', ['forceDeleted'])->where('model', '=', $module)->get(); 76 | /* 77 | * Send to Job Process 78 | */ 79 | (new HookJobProcess($search, $model, 'forceDeleted', $module))->send(); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/Pages/WebhookHistory.php: -------------------------------------------------------------------------------- 1 | webhookClient_Id = request('client_id'); 42 | } else { 43 | $this->redirect(url()->previous()); 44 | } 45 | } 46 | 47 | protected function getTableQuery(): Builder 48 | { 49 | return FilamentWebhookServerHistory::query()->where('webhook_client', '=', $this->webhookClient_Id); 50 | } 51 | 52 | protected function getTableColumns(): array 53 | { 54 | return [ 55 | TextColumn::make('uuid'), 56 | TextColumn::make('status_code'), 57 | TextColumn::make('errorMessage'), 58 | TextColumn::make('errorType'), 59 | TextColumn::make('attempt'), 60 | ]; 61 | } 62 | 63 | protected function getTableActions(): array 64 | { 65 | return [ 66 | Action::make('Go Back') 67 | ->url(Webhooks::getUrl()), 68 | ]; 69 | } 70 | 71 | protected function getActions(): array 72 | { 73 | return [ 74 | \Filament\Pages\Actions\Action::make('Go Back') 75 | ->button() 76 | ->icon('heroicon-o-arrow-left-circle') 77 | ->label( 78 | __( 79 | 'filament-webhook-server::default.pages.history.back' 80 | ) 81 | ) 82 | ->url(Webhooks::getUrl()), 83 | ]; 84 | } 85 | 86 | protected function getTableEmptyStateIcon(): ?string 87 | { 88 | return 'heroicon-o-bookmark'; 89 | } 90 | 91 | protected function getTableEmptyStateHeading(): ?string 92 | { 93 | return 'No transaction log yet'; 94 | } 95 | 96 | protected function getTablePollingInterval(): ?string 97 | { 98 | return config('filament-webhook-server.polling', '10s'); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/Pages/Webhooks.php: -------------------------------------------------------------------------------- 1 | null]; 45 | 46 | public function getHeading(): string 47 | { 48 | return __('filament-webhook-server::default.pages.heading'); 49 | } 50 | 51 | public static function getNavigationGroup(): ?string 52 | { 53 | return __('filament-webhook-server::default.pages.navigation.group'); 54 | } 55 | 56 | public static function getNavigationSort(): ?int 57 | { 58 | return config('filament-webhook-server.navigation.sort') ?? 0; 59 | } 60 | 61 | 62 | public function mount(): void 63 | { 64 | $this->form->fill(); 65 | } 66 | 67 | public static function getNavigationLabel(): string 68 | { 69 | return __('filament-webhook-server::default.pages.navigation.label'); 70 | } 71 | 72 | protected function getActions(): array 73 | { 74 | return [ 75 | Action::make('Add Webhook') 76 | ->button() 77 | ->label( 78 | __( 79 | 'filament-webhook-server::default.pages.button.add_new_webhook' 80 | ) 81 | ) 82 | ->action('openCreateModal'), 83 | ]; 84 | } 85 | 86 | public function openCreateModal(): void 87 | { 88 | $this->dispatch('open-modal', id: 'create-webhook'); 89 | } 90 | 91 | public function create(): void 92 | { 93 | $data = $this->form->getState(); 94 | $webhookModel = new FilamentWebhookServer(); 95 | $webhookModel->name = $data['name']; 96 | $webhookModel->description = $data['description']; 97 | $webhookModel->url = $data['url']; 98 | $webhookModel->method = $data['method']; 99 | $webhookModel->model = ucfirst($data['model']); 100 | $webhookModel->header = $data['header']; 101 | $webhookModel->data_option = $data['data_option']; 102 | $webhookModel->events = $data['events']; 103 | $webhookModel->verifySsl = $data['verifySsl']; 104 | $webhookModel->save(); 105 | $this->dispatch('close-modal', id: 'create-webhook'); 106 | Notification::make() 107 | ->success() 108 | ->body(__('filament-webhook-server::default.notification.create.success')) 109 | ->send(); 110 | } 111 | 112 | protected function getFormSchema(): array 113 | { 114 | return [Grid::make(1)->schema( 115 | [ 116 | TextInput::make('name')->minLength(2)->maxLength(255)->required(), 117 | Textarea::make('description')->required(), 118 | TextInput::make('url')->label('Url to Notify')->url()->required(), 119 | Select::make('method')->options( 120 | [ 121 | 'post' => 'Post', 122 | 'get' => 'Get', 123 | ] 124 | )->required(), 125 | Select::make('model')->options($this->getAllModelNames())->required(), 126 | KeyValue::make('header'), 127 | Radio::make('data_option')->options( 128 | [ 129 | 'all' => 'All Model Data', 130 | 'summary' => 'Summary', 131 | 'custom' => 'Custom', 132 | ] 133 | )->descriptions( 134 | [ 135 | 'all' => 'All Data of the event triggered', 136 | 'summary' => 'Push only the ID if the record that trigger an event and its timestamp', 137 | 'custom' => 'Only data defined on model`s toWebhookPayload method', 138 | ] 139 | )->columns(2)->required(), 140 | CheckboxList::make('events') 141 | ->options([ 142 | 'created' => 'Created', 143 | 'updated' => 'Updated', 144 | 'deleted' => 'Deleted', 145 | 'restored' => 'Restored', 146 | 'forceDeleted' => 'Force Deleted', 147 | ]) 148 | ->columns(2), 149 | Radio::make('verifySsl')->label('Verify SSL?')->boolean()->inline()->required(), 150 | 151 | ] 152 | ), 153 | ]; 154 | } 155 | 156 | protected function getFormStatePath(): string 157 | { 158 | return 'data'; 159 | } 160 | 161 | protected function getTableViewForm(): array 162 | { 163 | return [Grid::make(1)->schema( 164 | [ 165 | TextInput::make('name')->minLength(2)->maxLength(255)->required(), 166 | Textarea::make('description')->required(), 167 | TextInput::make('url')->label('Url to Notify')->url()->required(), 168 | Select::make('method')->options( 169 | [ 170 | 'post' => 'Post', 171 | 'get' => 'Get', 172 | ] 173 | )->required(), 174 | TextInput::make('model')->required(), 175 | KeyValue::make('header'), 176 | Radio::make('data_option')->options( 177 | [ 178 | 'all' => 'All Model Data', 179 | 'summary' => 'Summary', 180 | 'custom' => 'Custom', 181 | ] 182 | )->descriptions( 183 | [ 184 | 'all' => 'All Data of the event triggered', 185 | 'summary' => 'Push only the ID if the record that trigger an event and its timestamp', 186 | 'custom' => 'Only data defined on model`s toWebhookPayload method', 187 | ] 188 | )->columns(2)->required(), 189 | CheckboxList::make('events') 190 | ->options([ 191 | 'created' => 'Created', 192 | 'updated' => 'Updated', 193 | 'deleted' => 'Deleted', 194 | 'restored' => 'Restored', 195 | 'forceDeleted' => 'Force Deleted', 196 | ]) 197 | ->columns(2), 198 | Radio::make('verifySsl')->label('Verify SSL?')->boolean()->inline()->required(), 199 | 200 | ] 201 | ), 202 | ]; 203 | } 204 | 205 | protected function getTableActions(): array 206 | { 207 | return [ 208 | Tables\Actions\Action::make('View Logs') 209 | ->visible(fn (): bool => config('filament-webhook-server.webhook.keep_history')) 210 | ->icon('heroicon-o-document-text') 211 | ->color('success') 212 | ->url(fn (FilamentWebhookServer $record): string => WebhookHistory::getUrl(['client_id' => $record->id])), 213 | Tables\Actions\ViewAction::make('view') 214 | ->mountUsing(fn (ComponentContainer $form, FilamentWebhookServer $record) => $form->fill([ 215 | 'name' => $record->name, 216 | 'description' => $record->description, 217 | 'url' => $record->url, 218 | 'method' => $record->method, 219 | 'model' => $record->model, 220 | 'header' => $record->header, 221 | 'data_option' => $record->data_option, 222 | 'verifySsl' => $record->verifySsl, 223 | 'events' => $record->events, 224 | ])) 225 | ->form($this->getTableViewForm()), 226 | Tables\Actions\DeleteAction::make('delete') 227 | ->requiresConfirmation(), 228 | ]; 229 | } 230 | 231 | protected function getTableQuery(): \Illuminate\Database\Eloquent\Builder 232 | { 233 | return FilamentWebhookServer::query(); 234 | } 235 | 236 | protected function getTableColumns(): array 237 | { 238 | return [ 239 | TextColumn::make('name'), 240 | TextColumn::make('description'), 241 | TextColumn::make('model') 242 | ->label('Module'), 243 | TextColumn::make('url'), 244 | BooleanColumn::make('verifySsl'), 245 | Tables\Columns\TagsColumn::make('events')->separator(','), 246 | 247 | ]; 248 | } 249 | 250 | protected function isTablePaginationEnabled(): bool 251 | { 252 | return true; 253 | } 254 | 255 | protected function getTableEmptyStateIcon(): ?string 256 | { 257 | return config('filament-webhook-server.navigation.icon') ?? 'heroicon-s-arrow-up-on-square-stack'; 258 | } 259 | 260 | protected function getTableEmptyStateHeading(): ?string 261 | { 262 | return 'No Webhook'; 263 | } 264 | 265 | protected function getTableEmptyStateDescription(): ?string 266 | { 267 | return 'You may create a webhook using the button below.'; 268 | } 269 | 270 | protected function getTableEmptyStateActions(): array 271 | { 272 | return [ 273 | Tables\Actions\Action::make('create') 274 | ->label('Create post') 275 | ->button() 276 | ->label( 277 | __( 278 | 'filament-webhook-server::default.pages.button.add_new_webhook' 279 | ) 280 | ) 281 | ->action('openCreateModal'), 282 | ]; 283 | } 284 | 285 | protected function getTablePollingInterval(): ?string 286 | { 287 | return config('filament-webhook-server.polling', '10s'); 288 | } 289 | } 290 | -------------------------------------------------------------------------------- /src/Traits/helper.php: -------------------------------------------------------------------------------- 1 | setModel($model) 26 | ->setDataOption($dataOption) 27 | ->setEvent($event) 28 | ->setModule($module) 29 | ->generate(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/WebhookPlugin.php: -------------------------------------------------------------------------------- 1 | pages(config('filament-webhook-server.pages')); 21 | } 22 | 23 | public static function make(): static 24 | { 25 | return app(static::class); 26 | } 27 | 28 | public static function get(): static 29 | { 30 | /** @var static $plugin */ 31 | $plugin = filament(app(static::class)->getId()); 32 | 33 | return $plugin; 34 | } 35 | 36 | public function boot(Panel $panel): void 37 | { 38 | // TODO: Implement boot() method. 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /tailwind.config.js: -------------------------------------------------------------------------------- 1 | const colors = require('tailwindcss/colors') 2 | 3 | /** @type {import('tailwindcss').Config} */ 4 | module.exports = { 5 | content: ['./resources/views/**/*.blade.php', './src/**/*.php'], 6 | darkMode: 'class', 7 | theme: { 8 | extend: { 9 | colors: { 10 | danger: colors.rose, 11 | primary: colors.amber, 12 | success: colors.green, 13 | warning: colors.amber, 14 | }, 15 | }, 16 | }, 17 | corePlugins: { 18 | preflight: false, 19 | }, 20 | plugins: [], 21 | } 22 | --------------------------------------------------------------------------------