jeffersongoncalves/filament-cookie-consent
composer require jeffersongoncalves/filament-cookie-consent:^3.2
php artisan vendor:publish --provider="Spatie\LaravelSettings\LaravelSettingsServiceProvider" --tag="migrations"
php artisan vendor:publish --tag=cookie-consent-settings-migrations
php artisan migrate
PanelProvider:
use JeffersonGoncalves\Filament\CookieConsent\CookieConsentPlugin;
public function panel(Panel $panel): Panel {
return $panel->plugins([
CookieConsentPlugin::make(),
]);
}
Admin Configuration:
CookieConsentPlugin::make()
->settingsPage(true) // Default: true
->group('Legal') // Customize navigation group
Conditional Rendering:
Multi-Language Support:
Cookie Category Management:
analytics, marketing) in the settings page and map them to Laravel’s cookie groups:
// In a service provider or config file
'cookie_consent' => [
'categories' => [
'analytics' => ['google_analytics', 'matomo'],
'marketing' => ['facebook_pixel'],
],
]
Custom Scripts/Styles:
php artisan vendor:publish --tag=cookie-consent-views
resources/views/vendor/cookie-consent/banner.blade.php.Filament Version Mismatch:
composer require jeffersongoncalves/filament-cookie-consent:^2.3
Missing Migrations:
php artisan migrate after publishing settings migrations will break the settings page.Render Hook Conflicts:
body.end or head.end hooks.Cookie Persistence:
APP_URL and session driver are configured correctly in .env.settings table or using Tinker:
php artisan tinker
>>> \Spatie\LaravelSettings\Setting::get('cookie_consent');
php artisan filament:cache:clear
// In a service provider
event(new \JeffersonGoncalves\LaravelCookieConsent\Events\ConsentGiven($categories));
Custom Consent Logic:
php artisan vendor:publish --tag=cookie-consent-middleware
App\Http\Middleware\CheckCookieConsent to add custom logic (e.g., redirect non-consenting users).Dynamic Content:
// In a service provider
\Spatie\LaravelSettings\Setting::macro('cookieConsent', function () {
return collect([
'header' => 'Custom Header',
// ... other settings
]);
});
Multi-Tenant Support:
// In a middleware
\JeffersonGoncalves\LaravelCookieConsent\Facades\CookieConsent::setTenant($tenantId);
Testing:
// In a test
$this->app->make('filament')->registerRenderHook(
'body.end',
fn () => '<div data-testid="cookie-banner">Mock Banner</div>'
);
How can I help you explore Laravel packages today?