Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Filament Webhook Client Laravel Package

tapp/filament-webhook-client

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Prerequisites: Ensure you have Spatie Webhook Client installed and configured in your Laravel project.

  2. Installation:

    composer require tapp/filament-webhook-client:"^4.0"
    
  3. Publish Config:

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

    (Optional: Publish translations with --tag="filament-webhook-client-translations")

  4. Register Plugin: Add the plugin to your Filament panel in app/Providers/Filament/AdminPanelProvider.php:

    use Tapp\FilamentWebhookClient\FilamentWebhookClientPlugin;
    
    public function panel(Panel $panel): Panel
    {
        return $panel
            ->plugins([
                FilamentWebhookClientPlugin::make(),
            ]);
    }
    
  5. First Use Case: Access the /admin/webhook-calls route in your Filament panel to view and manage webhook calls. The resource provides a pre-built UI for listing, filtering, and inspecting webhook payloads.


Implementation Patterns

Core Workflows

  1. Webhook Call Management:

    • List View: Filter webhook calls by status (success/failure), timestamp, or endpoint.
    • Detail View: Inspect raw payloads, headers, and metadata in a formatted JSON display.
    • Actions: Use Filament’s built-in actions (e.g., bulk delete, export) via the resource’s actions() method.
  2. Policy Integration: Extend the default WebhookCallPolicy to restrict access:

    // config/filament-webhook-client.php
    'policies' => [
        'webhook-call' => App\Policies\CustomWebhookCallPolicy::class,
    ],
    

    Define custom policies in app/Policies/CustomWebhookCallPolicy.php:

    public function viewAny(User $user): bool
    {
        return $user->hasRole('webhook_admin');
    }
    
  3. Customization: Override the resource class to add fields or modify behavior:

    // app/Providers/Filament/AdminPanelProvider.php
    FilamentWebhookClientPlugin::make()
        ->resourceClass(CustomWebhookCallResource::class),
    

    Example CustomWebhookCallResource:

    namespace App\Filament\Resources;
    
    use Tapp\FilamentWebhookClient\Resources\WebhookCallResource as BaseResource;
    
    class CustomWebhookCallResource extends BaseResource
    {
        protected static ?string $model = \Spatie\WebhookClient\Models\WebhookCall::class;
    
        public static function table(Table $table): Table
        {
            return $table
                ->columns([
                    // Add custom columns
                    Tables\Columns\TextColumn::make('custom_field')
                        ->label('Custom Label'),
                ]);
        }
    }
    
  4. Navigation: Customize the plugin’s navigation position or icon in the config:

    'navigation' => [
        'sort' => 2, // Adjust position
        'icon' => 'heroicon-o-bell-alert', // Use a different icon
    ],
    
  5. Testing: Test webhook interactions using Spatie’s testing tools alongside Filament’s UI:

    use Spatie\WebhookClient\WebhookCall;
    
    public function test_webhook_call_management()
    {
        $call = WebhookCall::factory()->create();
        $this->actingAs($user)
             ->get('/admin/webhook-calls')
             ->assertSee($call->id);
    }
    

Gotchas and Tips

Pitfalls

  1. Missing Spatie Webhook Client: The package requires Spatie’s laravel-webhook-client to be installed. Forgetting this will cause runtime errors.

  2. Policy Conflicts: Overriding the default policy without updating the config will result in no permissions being applied. Always update the policies array in filament-webhook-client.php when extending policies.

  3. JSON Formatting: The package displays payloads as formatted JSON by default. For large payloads, this may impact performance. Consider adding a TextColumn with truncation for better UX:

    TextColumn::make('payload')
        ->limit(200)
        ->toggleable(isToggledHiddenByDefault: true),
    
  4. Filament Version Mismatch: Ensure compatibility between Filament versions (e.g., v4.x of this package requires Filament 4.x/5.x). Mixing versions may break the UI or functionality.

  5. Translation Keys: Custom translations require publishing the translations file and updating language files. Default keys are prefixed with filament-webhook-client::.

Debugging Tips

  1. Log Webhook Calls: Enable Spatie’s logging to debug webhook processing:

    'logging' => true, // In config/webhook-client.php
    
  2. Check Resource Registration: Verify the plugin is registered in panel()->plugins(). Missing registration will hide the resource entirely.

  3. Clear Filament Cache: After customizing the resource or config, clear Filament’s cache:

    php artisan filament:cache-reset
    
  4. Payload Inspection: Use Laravel’s dd() or dump() in a custom resource method to inspect payloads during development:

    public static function getPages(): array
    {
        $pages = parent::getPages();
        $pages['view'] = fn (Page $page) => $page
            ->modifyQueryUsing(fn (QueryBuilder $query) => $query->limit(1))
            ->header(fn (PageHeader $header) => $header
                ->description(fn (WebhookCall $record) => dd($record->payload)));
        return $pages;
    }
    

Extension Points

  1. Custom Actions: Add bulk actions or custom buttons to the resource table:

    public static function table(Table $table): Table
    {
        return $table
            ->actions([
                Action::make('retry')
                    ->action(fn (WebhookCall $record) => $record->retry())
                    ->visible(fn (WebhookCall $record) => $record->failed()),
            ]);
    }
    
  2. Webhook Endpoint Management: Extend the package to manage webhook endpoints (e.g., using Spatie’s Webhook model) by creating a separate resource and linking it to the plugin.

  3. Real-Time Updates: Use Filament’s livewire components to add real-time webhook status updates (e.g., polling the API for new calls):

    use Livewire\Component;
    
    class WebhookCallLivewire extends Component
    {
        public function refreshCalls()
        {
            $this->dispatch('refreshWebhookCalls');
        }
    }
    
  4. Export Functionality: Add CSV/Excel exports for webhook logs:

    public static function table(Table $table): Table
    {
        return $table
            ->actions([
                Tables\Actions\ExportAction::make(),
            ]);
    }
    
  5. Dark Mode Support: Ensure your customizations respect Filament’s dark mode by using Filament’s built-in styling classes (e.g., dark:bg-gray-800).

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony