muazzambuilds/filament-ban

Ban and suspend users from Filament — middleware blocks panel, API, and login.

Maintainers

Package info

github.com/muazzambuilds/filament-ban

pkg:composer/muazzambuilds/filament-ban

Transparency log

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 4

Open Issues: 0

dev-main 2026-07-14 07:13 UTC

This package is auto-updated.

Last update: 2026-07-14 07:15:12 UTC


README

Filament Ban

Filament Ban

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.

Users table with Ban, Suspend, and Unban actions

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 banned middleware (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:

Buy Me A Coffee

License

MIT