tapp/filament-webhook-client
spatie/laravel-webhook-client is installed and configured in your Laravel project.composer require tapp/filament-webhook-client:"^4.0"
php artisan vendor:publish --tag="filament-webhook-client-config"
app/Providers/Filament/PluginServiceProvider.php:
public function register(): void
{
Filament::registerPlugin(
Tapp\FilamentWebhookClient\FilamentWebhookClientPlugin::make()
);
}
/admin/resources/webhooks) to see all registered webhooks.Resource Integration:
Spatie\WebhookClient\Models\Webhook.php artisan vendor:publish --tag="filament-webhook-client-resources"
app/Filament/Resources/WebhookResource.php.Policy Management:
ViewWebhooks, ManageWebhooks).app/Providers/Filament/AdminPanelProvider.php:
$panel->userMenuItems([
Filament\Panel\UserMenuItem::make('Webhooks')
->url(fn (Filament\User $user) => $user->can('view webhooks') ? '/admin/resources/webhooks' : null),
]);
Webhook Events:
WebhookReceived) in EventServiceProvider:
protected $listen = [
\Spatie\WebhookClient\Events\WebhookReceived::class => [
\App\Listeners\HandleWebhook::class,
],
];
Testing Webhooks:
POST /webhook/test).$webhook = Webhook::find(1);
$webhook->test();
// In a webhook handler
$apiKey = Filament::getSettings()['stripe_api_key'];
public static function getRelations(): array
{
return [
Tables\Relationships\BelongsToMany::make('Services')
->relationship('services', Service::class)
->title('Service'),
];
}
use Filament\Notifications\Notification;
// In a listener
Notification::make()
->title('Webhook Received')
->success()
->send();
Missing Spatie Webhook Client:
Class 'Spatie\WebhookClient\Models\Webhook' not found.spatie/laravel-webhook-client is installed and configured before installing this package.Policy Conflicts:
Call to undefined method Filament\Resources\Resource::can().Filament/AdminPanelProvider.php and that the FilamentWebhookClientPlugin is registered.Webhook Secret Mismatch:
Invalid signature.webhook_secret in .env matches the one configured in the Filament UI or code.Resource Overrides Not Loading:
WebhookResource are ignored.php artisan filament:cache-reset
// app/Http/Middleware/LogWebhookPayload.php
public function handle($request, Closure $next)
{
if ($request->is('webhook/*')) {
\Log::info('Webhook Payload', $request->all());
}
return $next($request);
}
ngrok http 8000
Configure the webhook URL in Filament to point to your ngrok endpoint (e.g., https://abc123.ngrok.io/webhook/stripe).Custom Webhook Models:
Extend the default Webhook model to add custom fields:
// app/Models/CustomWebhook.php
class CustomWebhook extends \Spatie\WebhookClient\Models\Webhook
{
protected $casts = [
'custom_field' => 'boolean',
];
}
Update the Filament resource to use the custom model.
Add Custom Actions:
Extend the WebhookResource to include custom actions (e.g., "Regenerate Secret"):
public static function getActions(): array
{
return [
Actions\Action::make('regenerateSecret')
->action(function (Webhook $record) {
$record->secret = Str::random(40);
$record->save();
}),
];
}
Webhook Widgets: Create Filament widgets to display webhook statistics (e.g., "Webhooks Received Today"):
// app/Filament/Widgets/WebhookStats.php
class WebhookStats extends Widget
{
protected static string $view = 'filament-webhook-client::widgets.stats';
public function mount(): void
{
$this->stats = Webhook::query()
->where('created_at', '>=', now()->startOfDay())
->count();
}
}
Webhook Event Broadcasting: Broadcast webhook events to Filament’s real-time system (e.g., using Laravel Echo):
// In a listener
broadcast(new WebhookReceived($webhook))->toOthers();
Listen for broadcasts in a Filament Livewire component to update the UI dynamically.
Webhook model and update the Filament resource accordingly.webhook_client.secret_length):
// config/filament-webhook-client.php
'secret_length' => 64,
How can I help you explore Laravel packages today?