Installation
Run composer require winex/sentinel and execute php artisan sentinel:install followed by php artisan migrate. This sets up the core database tables for license management.
Filament Integration
Register the SentinelProvider in your Filament panel configuration:
public function panel(Panel $panel): Panel {
return $panel
->requiresTenantSubscription()
->tenantBillingProvider(new SentinelProvider());
}
First Use Case
Add the SentinelPage to your Filament panel:
->pages([
SentinelPage::class,
]);
This immediately exposes a dashboard for managing licenses, trials, and billing.
database/migrations/ for schema changes (e.g., licenses, subscriptions).Filament/Pages/SentinelPage.php for UI components and logic.SentinelProvider.php for core integration hooks.License Management
Sentinel::validateLicense($licenseKey) to check license validity.Sentinel::activateLicense($licenseKey, $user) to bind a license to a tenant/user.Sentinel::checkTrialExpiry($user).Billing Integration
.env (e.g., MONTHLY_PLAN=30) and fetch them via:
$monthlyPlan = config('sentinel.plans.monthly');
tenant.subscription.created or tenant.subscription.cancelled events to trigger actions.Filament-Specific Patterns
if (auth()->user()->tenant->isSubscribed()) {
// Grant access
}
SentinelPage to display subscription status, upgrade buttons, and billing history.API Endpoints
Route::post('/validate-license', [SentinelController::class, 'validate']);
SentinelPolicy to restrict access to resources based on subscription status.SentinelServiceProvider and overriding handleWebhook().resources/lang/vendor/sentinel.Migration Timestamps
sentinel:install command hardcodes the migration timestamp. If you modify migrations later, run:
php artisan migrate:fresh --env=local
to avoid conflicts.Plan Configuration
.env values (MONTHLY_PLAN, ANNUAL_PLAN) must be integers. Non-numeric values will throw InvalidArgumentException.Filament Tenant Sync
tenantBillingProvider is set before requiresTenantSubscription() in your panel configuration. Order matters.License Key Format
UUID format. Custom formats may require extending LicenseValidator.logs/laravel.log for SentinelWebhook events. Enable debug mode:
SENTINEL_DEBUG=true
php artisan sentinel:prune to clean up expired trials/licenses (runs daily by default).Custom Validators
Override Winex\Sentinel\Contracts\LicenseValidator to add logic (e.g., domain validation):
public function validate($licenseKey, $tenant) {
// Custom logic
return $this->validator->passes();
}
Subscription Logic
Extend Winex\Sentinel\Services\SubscriptionService to modify trial periods or pricing:
public function calculateTrialDays(): int {
return 14; // Override default
}
Filament Widgets
Add custom widgets to SentinelPage by publishing views:
php artisan vendor:publish --tag=sentinel-views
Then extend resources/views/vendor/sentinel/.
Multi-Tenant Support For multi-tenant setups, bind the license to the tenant model:
Sentinel::activateLicense($key, auth()->user()->tenant);
How can I help you explore Laravel packages today?