Ban Guard
CommunityBan or suspend users from your panel, with middleware that also blocks API access and login.
filament/
namespace. Review the source and install at your own risk. Found
malware or an unresolved security issue the author won't
address?
Report it
.
Author:
Muazzam Ali khan
Documentation
Ban and suspend users from Filament v5. Add actions to your user resource; middleware blocks the panel, API, and login when an account is banned or suspended.
#Requirements
| Dependency | Version |
|---|---|
| PHP | ^8.2 |
| Laravel | ^11 / ^12 |
| Filament | ^5.0 |
#Installation
composer require muazzambuilds/filament-ban
Publish the config and migration:
php artisan vendor:publish --tag=filament-ban-config
php artisan vendor:publish --tag=filament-ban-migrations
php artisan migrate
#Setup
#1. Add the trait to your user model
use MuazzamBuilds\FilamentBan\Concerns\Bannable;
class User extends Authenticatable
{
use Bannable;
}
#2. Register the panel plugin
use MuazzamBuilds\FilamentBan\BanPlugin;
public function panel(Panel $panel): Panel
{
return $panel
->plugin(BanPlugin::make());
}
This attaches auth middleware so banned / suspended users cannot use the panel (and are logged out).
#3. Protect API routes
Route::middleware(['auth:sanctum', 'banned'])->group(function () {
// …
});
Login is blocked automatically via Laravel’s Validated auth event — no custom login page required.
#4. Add actions to your user resource
use MuazzamBuilds\FilamentBan\Actions\BanAction;
use MuazzamBuilds\FilamentBan\Actions\SuspendAction;
use MuazzamBuilds\FilamentBan\Actions\UnbanAction;
use MuazzamBuilds\FilamentBan\Actions\UnsuspendAction;
public function getRecordActions(): array
{
return [
BanAction::make(),
UnbanAction::make(),
SuspendAction::make(),
UnsuspendAction::make(),
];
}
Or on a table:
->recordActions([
BanAction::make(),
UnbanAction::make(),
SuspendAction::make(),
UnsuspendAction::make(),
])
#Behaviour
| State | Effect |
|---|---|
Banned (banned_at set) |
Permanent block until unbanned |
Suspended (suspended_until in the future) |
Temporary block; lifts automatically when the time passes |
Blocked users:
- Cannot log in (validation error with ban/suspend message)
- Are rejected from Filament panels (plugin middleware)
- Are rejected from routes using the
bannedmiddleware (API-friendly JSON 403)
#Model API
$user->ban('Spam');
$user->unban();
$user->suspend(now()->addDays(7), 'Cool down');
$user->unsuspend();
$user->isBanned();
$user->isSuspended();
$user->isAccessBlocked();
Query scopes: User::banned(), User::notBanned(), User::suspended(), User::accessBlocked().
#Config
// config/filament-ban.php
'user_model' => 'App\\Models\\User',
'logout' => true,
'api_status' => 403,
'web_redirect' => null, // route name or path; null throws AuthenticationException
#Support
If this package helps you, consider supporting development:
#License
MIT
The author
AI Engineer & Laravel Developer building intelligent SaaS products, AI agents, and Filament applications. I help founders ship production-ready software — from AI automation to Laravel & Filament admin panels, SaaS platforms, and AI-powered ecommerce. I publish plugins and tutorials as Muazzam Builds.
What I'm Building
- AI Agents & business automation
- Laravel & Filament applications
- SaaS products and AI ecommerce
Tech Stack
Laravel • PHP • Filament • Livewire • MySQL • Python • Docker • OpenAI • Cloudflare • AWS
Connect
From the same author
Turnstile
Cloudflare Turnstile panel plugin — register once to auto-protect login, registration, and password reset.
Author:
Muazzam Ali khan
AI Actions
OpenAI-powered actions for Filament v5. Drop complete Summarize, Rewrite, and Classify actions onto tables and forms — no DIY prompt wiring. Install via Composer, set OPENAI_API_KEY, then attach actions to table record actions or page header actions. Optionally write results back to a model attribute with applyTo().
Author:
Muazzam Ali khan
Panel Branding
Rebrand your Filament panel from a settings page — logos, colors, fonts, layout, footer, and custom CSS, with per-panel and optional per-tenant support.
Author:
Muazzam Ali khan
Featured Plugins
A selection of plugins curated by the Filament team
Blueprint
Filament Blueprint is a premium Laravel Boost extension that helps AI agents produce accurate, detailed implementation plans and security reports for Filament apps.
Filament
Spotlight Pro
Browse your Filament Panel with ease. Filament Spotlight Pro adds a Spotlight/Raycast like Command Palette to your Filament Panel.
Dennis Koch
Custom Fields
Eliminate custom field migrations forever. Let your users create and manage form fields directly in Filament admin panels with 20+ built-in field types, validation, and zero database changes.
Relaticle