jeffersongoncalves/filament-ban 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jeffersongoncalves/filament-ban

Composer 安装命令:

composer require jeffersongoncalves/filament-ban

包简介

Ban and unban any Eloquent model directly from Filament tables with ready-to-use actions, bulk actions, an icon column and a status filter, powered by cybercog/laravel-ban.

README 文档

README

Filament Ban

Filament Ban

Latest Version on Packagist GitHub Code Style Action Status Total Downloads License

Ban and unban any Eloquent model directly from your Filament panel. This package wraps cybercog/laravel-ban and ships ready-to-use actions, bulk actions, an icon column and a status filter for your Filament resources and tables. Inspired by cybercog/laravel-nova-ban.

Version Compatibility

Filament Laravel PHP Branch Version
v3 10 / 11 8.1+ 1.x ^1.0
v4 11 / 12 8.2+ 2.x ^2.0
v5 11.28 / 12 / 13 8.2+ 3.x ^3.0

All tags use plain SemVer without the v prefix (e.g. 3.0.0).

Installation

You can install the package via composer:

composer require jeffersongoncalves/filament-ban

Publish and run the cybercog/laravel-ban migration (creates the bans table):

php artisan vendor:publish --provider="Cog\Laravel\Ban\Providers\BanServiceProvider" --tag="migrations"
php artisan migrate

Then add a nullable banned_at timestamp column to each bannable model's table:

Schema::table('users', function (Blueprint $table) {
    $table->timestamp('banned_at')->nullable();
});

Preparing your model

Make any Eloquent model bannable by implementing the contract and using the trait:

use Cog\Contracts\Ban\Bannable as BannableContract;
use Cog\Laravel\Ban\Traits\Bannable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements BannableContract
{
    use Bannable;
}

Usage

Actions

Add ban / unban buttons to a resource table row. Each action shows only when relevant (Ban when the record is not banned, Unban when it is). BanAction opens a modal where you can set an optional comment and an optional expiration date.

use JeffersonGoncalves\Filament\Ban\Actions\BanAction;
use JeffersonGoncalves\Filament\Ban\Actions\UnbanAction;

public function table(Table $table): Table
{
    return $table
        ->recordActions([
            BanAction::make(),
            UnbanAction::make(),
        ]);
}

Bulk actions

use JeffersonGoncalves\Filament\Ban\Actions\BanBulkAction;
use JeffersonGoncalves\Filament\Ban\Actions\UnbanBulkAction;

$table->toolbarActions([
    BanBulkAction::make(),
    UnbanBulkAction::make(),
]);

Column

Display the current ban status as a boolean icon:

use JeffersonGoncalves\Filament\Ban\Tables\Columns\BanColumn;

$table->columns([
    BanColumn::make(),
]);

Filter

Filter records by ban status (uses the onlyBanned / withoutBanned scopes):

use JeffersonGoncalves\Filament\Ban\Tables\Filters\BanFilter;

$table->filters([
    BanFilter::make(),
]);

Development

# Run static analysis
composer analyse

# Run tests
composer test

# Format code
composer format

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-24