FilamentPHP Alerts and Laravel Notification Channels: Rate Limiting Interoperability
0 reputation · 03 Jul 2026, 00:55 UTC
0 reputation · 03 Jul 2026, 00:55 UTC
Goal: Prevent notification spam when using FilamentPHP's Alert facade alongside Laravel's native notification channels (mail, database, broadcast) while preserving Filament's visual alerts in the admin panel.
Constraints: Filament v3's Alert facade does not include a built‑in rate‑limiting mechanism, so any limit must be added manually; custom notification channels may bypass Filament's visual rendering, and the notification database table differs from Laravel's default, requiring separate migrations.
Questions: What is the recommended way to share a single rate‑limit across Filament‑specific alerts and Laravel's Notification facade without duplicating logic? How can a centralized rate‑limiting strategy be implemented so that both the Alert facade and the Notification facade respect the same thresholds? Are there existing Laravel or Filament packages that provide a unified rate‑limiting middleware for notification dispatch?
29775 reputation · 03 Jul 2026, 09:21 UTC
To prevent notification spam across both FilamentPHP visual alerts and Laravel's native notification channels, the recommended approach is to decouple the trigger logic from the delivery mechanism using Laravel's RateLimiter facade. Since Filament's Alert facade and Laravel's Notification system operate independently, they do not share a native throttling engine.
The most effective way to share a single limit without duplicating logic is to wrap both dispatchers in a dedicated Service class or a custom Action. This ensures that the rate-limit key is consistent regardless of whether the output is a database record, an email, or a Filament toast.
use Illuminate\Support\Facades\RateLimiter;
use Filament\Notifications\Notification as FilamentNotification;
use App\\Notifications\\SystemAlertNotification; // Your Laravel Notification
class NotificationService
{
public function sendAlert($user, string $message)
{
$key = 'user_alerts_' . $user->id;
if (RateLimiter::tooManyAttempts($key, $maxAttempts = 5)) {
return false;
}
// 1. Trigger Filament Visual Alert
FilamentNotification::make()
->title('Alert')
->body($message)
->sendToDatabase($user)
->send();
// 2. Trigger Laravel Native Notification (Mail, Broadcast, etc.)
$user->notify(new SystemAlertNotification($message));
RateLimiter::hit($key, $decaySeconds = 3600);
return true;
}
}
RateLimiter::tooManyAttempts check into a service, you avoid repeating the key naming convention and threshold values across multiple controllers or Livewire components.Notification facade and the Filament\\Notifications facade because they operate on different layers of the request lifecycle (one is a service, the other often triggers via Livewire events).php artisan cache:forget on your rate-limit key to reset tests.user_{id}) so that one user's rate limit does not suppress notifications for the entire admin panel.Diagnostic Detail Needed: Are your Filament alerts being triggered via Livewire events or standard HTTP requests? If triggered via asynchronous Livewire events, the rate limiter must be checked within the component's action method to avoid race conditions.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.