Skip to content

Latest commit

 

History

History
71 lines (50 loc) · 2.75 KB

customization.md

File metadata and controls

71 lines (50 loc) · 2.75 KB

Customization

Eloquent Webhooks provides a configuration file that allows you to customize the package to fit your application's architecture.

Configuration File

If you haven't already published the configuration file, you can do so using artisan:

php artisan vendor:publish --tag="webhooks-config"

This publishes the config/webhooks.php file, which includes the following customizable sections:

Model Configuration

You can swap out the default models for your own by updating the config/webhooks.php file or using environment variables:

'user_model' => env('WEBHOOKS_USER_MODEL', 'App\\Models\\User'),
'workspace_model' => env('WEBHOOKS_WORKSPACE_MODEL', 'App\\Models\\Workspace'),
'project_model' => env('WEBHOOKS_PROJECT_MODEL', 'App\\Models\\Project'),

Route Configuration

The package registers API routes automatically. You can customize the route prefix, middleware, or disable route registration entirely:

'register_routes' => env('WEBHOOKS_REGISTER_ROUTES', true),
'route_prefix' => env('WEBHOOKS_ROUTE_PREFIX', ''),
'route_middleware' => ['auth:sanctum'],
'ingress_middleware' => [],

route_middleware applies to webhook management routes, including event listing. ingress_middleware applies only to POST /webhooks/ingress/{token} and does not inherit the management middleware. Its default is an empty list because webhook senders authenticate with the URL token rather than a Sanctum login. The ingress controller rejects unknown tokens and inactive webhooks. Global application middleware still runs.

Add middleware aliases or classes to the published configuration. For example, Laravel's throttle middleware can limit incoming requests to 60 per minute:

'ingress_middleware' => ['throttle:60,1'],

Applications can also add middleware that checks a provider's signature against the original request body. Incoming signature verification is not built into the package. Adding auth:sanctum here requires senders to supply credentials accepted by the application's Sanctum guard.

route_prefix applies to both groups. For example, api makes the ingress path /api/webhooks/ingress/{token}. Setting register_routes to false disables both groups so the application can register its own routes.

Feature Flags

You can enable or disable built-in support for Workspace scoping, Project scoping, and event tracking based on your needs:

'workspace_scoped' => env('WEBHOOKS_WORKSPACE_SCOPED', true),
'project_scoped' => env('WEBHOOKS_PROJECT_SCOPED', true),
'track_events' => env('WEBHOOKS_TRACK_EVENTS', true),

Activity Logging Integration

If the whilesmart/activities package is installed, Eloquent Webhooks automatically detects it and logs an activity whenever a webhook event is processed.