Banhammer
CommunityBan resources in your Filament project.
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:
Gerenuk
Documentation
- Table of Contents
- Version Compatibility
- Installation
- Usage
- Testing
- Screenshots
- Changelog
- Contributing
- Security Vulnerabilities
- Credits
- License
This package uses mchev/banhammer to add model banning functionality to filament.
#Table of Contents
- Introduction
- Version Compatibility
- Installation
- Usage
- Testing
- Screenshots
- Changelog
- Contributing
- Security Vulnerabilities
- Credits
- License
#Version Compatibility
| Plugin | Filament | Laravel | PHP |
|---|---|---|---|
| 1.x | 3.x | 10.x | 8.x |
| 1.x | 3.x | 11.x | 8.2|8.3 |
#Installation
This package depends on mchev/banhammer please follow the install guide there first.
You can install the package via composer:
composer require gerenuk/filament-banhammer
[!IMPORTANT] Ensure you have already installed mchev/banhammer before doing this.
You can publish the config file with:
php artisan vendor:publish --tag="filament-banhammer-config"
This is the contents of the published config file:
Click to expand!
return [
/*
* The name of the resource which the plugin should use.
*/
'resource' => \Gerenuk\FilamentBanhammer\Resources\BanhammerResource::class,
/*
* Whether an export action should be included on the resource.
*/
'show_export' => true,
/*
* Options for the actions.
*/
'actions' => [
/*
* Options for the ban action.
*/
'ban' => [
/*
* The title of the ban action.
*/
'label' => 'ban',
/*
* The colour of the ban action.
*/
'colour' => 'warning',
/*
* The symbol of the ban action.
*/
'icon' => 'heroicon-o-no-symbol',
/*
* Whether confirming is required when using the ban action.
*/
'require_confirmation' => true,
/*
* Notification options for the ban action.
*/
'notifications' => [
/*
* Whether a notification should be shown for the ban action.
*/
'show' => true,
/*
* Success options for the ban action notifications.
*/
'success' => [
/*
* The title of the success notification for the ban action.
*/
'title' => 'Banned',
],
/*
* Error options for the ban action notifications.
*/
'error' => [
/*
* The title of the error notification for the ban action.
*/
'title' => 'Failed',
],
],
],
/*
* Options for the edit ban action.
*/
'edit_ban' => [
/*
* The title of the edit ban action.
*/
'label' => 'edit ban',
/*
* The colour of the edit ban action.
*/
'colour' => 'warning',
/*
* The symbol of the edit ban action.
*/
'icon' => 'heroicon-o-pencil-square',
/*
* Whether confirming is required when using the edit ban action.
*/
'require_confirmation' => true,
/*
* Notification options for the edit ban action.
*/
'notifications' => [
/*
* Whether a notification should be shown for the edit ban action.
*/
'show' => true,
/*
* Success options for the edit ban action notifications.
*/
'success' => [
/*
* The title of the success notification for the edit ban action.
*/
'title' => 'Saved',
],
/*
* Error options for the edit ban action notifications.
*/
'error' => [
/*
* The title of the error notification for the edit ban action.
*/
'title' => 'Failed',
],
],
],
/*
* Options for the unban action.
*/
'unban' => [
/*
* The title of the unban action.
*/
'label' => 'unban',
/*
* The colour of the unban action.
*/
'colour' => 'warning',
/*
* The symbol of the unban action.
*/
'icon' => 'heroicon-o-no-symbol',
/*
* Whether confirming is required when using the unban action.
*/
'require_confirmation' => true,
/*
* Notification options for the unban action.
*/
'notifications' => [
/*
* Whether a notification should be shown for the unban action.
*/
'show' => true,
/*
* Success options for the unban action notifications.
*/
'success' => [
/*
* The title of the success notification for the unban action.
*/
'title' => 'Unbanned',
],
/*
* Error options for the unban action notifications.
*/
'error' => [
/*
* The title of the error notification for the unban action.
*/
'title' => 'Failed',
],
],
],
/*
* Options for the ban bulk action.
*/
'ban_bulk' => [
/*
* The title of the ban bulk action.
*/
'label' => 'ban',
/*
* The colour of the ban bulk action.
*/
'colour' => 'warning',
/*
* The symbol of the ban bulk action.
*/
'icon' => 'heroicon-o-no-symbol',
/*
* Whether confirming is required when using the ban bulk action.
*/
'require_confirmation' => true,
/*
* Notification options for the ban bulk action.
*/
'notifications' => [
/*
* Whether a notification should be shown for the ban bulk action.
*/
'show' => true,
/*
* Success options for the ban bulk action notifications.
*/
'success' => [
/*
* The title of the success notification for the ban bulk action.
*/
'title' => 'Banned',
],
/*
* Error options for the ban bulk action notifications.
*/
'error' => [
/*
* The title of the error notification for the ban bulk action.
*/
'title' => 'Failures',
],
],
],
/*
* Options for the edit ban bulk action.
*/
'edit_ban_bulk' => [
/*
* The title of the edit ban bulk action.
*/
'label' => 'edit ban',
/*
* The colour of the edit ban bulk action.
*/
'colour' => 'warning',
/*
* The symbol of the edit ban bulk action.
*/
'icon' => 'heroicon-o-pencil-square',
/*
* Whether confirming is required when using the edit ban bulk action.
*/
'require_confirmation' => true,
/*
* Notification options for the edit ban bulk action.
*/
'notifications' => [
/*
* Whether a notification should be shown for the edit ban bulk action.
*/
'show' => true,
/*
* Success options for the edit ban bulk action notifications.
*/
'success' => [
/*
* The title of the success notification for the edit ban bulk action.
*/
'title' => 'Saved',
],
/*
* Error options for the edit ban bulk action notifications.
*/
'error' => [
/*
* The title of the error notification for the edit ban bulk action.
*/
'title' => 'Failures',
],
],
],
/*
* Options for the unban bulk action.
*/
'unban_bulk' => [
/*
* The title of the unban bulk action.
*/
'label' => 'unban',
/*
* The colour of the unban bulk action.
*/
'colour' => 'warning',
/*
* The symbol of the unban bulk action.
*/
'icon' => 'heroicon-o-no-symbol',
/*
* Whether confirming is required when using the unban bulk action.
*/
'require_confirmation' => true,
/*
* Notification options for the unban bulk action.
*/
'notifications' => [
/*
* Whether a notification should be shown for the unban bulk action.
*/
'show' => true,
/*
* Success options for the unban bulk action notifications.
*/
'success' => [
/*
* The title of the success notification for the unban bulk action.
*/
'title' => 'Unbanned',
],
/*
* Error options for the unban bulk action notifications.
*/
'error' => [
/*
* The title of the error notification for the unban bulk action.
*/
'title' => 'Failures',
],
],
],
],
];
#Usage
You first need to register the plugin with Filament. This can be done inside of your PanelProvider, e.g. AdminPanelProvider.
<?php
namespace App\Providers\Filament;
use Filament\Panel;
use Filament\PanelProvider;
use Gerenuk\FilamentBanhammer\FilamentBanhammerPlugin;
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugin(FilamentBanhammerPlugin::make());
}
}
For each model you have added the use Banhammer trait to, you will also need to add the following method:
public function getFilamentBanhammerTitleAttribute()
{
return $this->name;
}
[!IMPORTANT] This specifies which property to be displayed in the bans resource.
#Ban
To be able to ban a resource simply add the Ban action:
use Filament\Tables\Table;
use Gerenuk\FilamentBanhammer\Resources\Actions\BanAction;
public static function table(Table $table): Table
{
return $table
->columns([
// ...
])
->actions([
BanAction::make(),
]);
}
#Unban
To be able to unban a resource simply add the Unban action:
use Filament\Tables\Table;
use Gerenuk\FilamentBanhammer\Resources\Actions\UnbanAction;
public static function table(Table $table): Table
{
return $table
->columns([
// ...
])
->actions([
UnbanAction::make(),
]);
}
A ban resource is included by default if you would prefer to use that instead.
#Ban Bulk
To be able to bulk ban a resource simply add the BanBulk action:
use Filament\Tables\Table;
use Gerenuk\FilamentBanhammer\Resources\Actions\BanBulkAction;
public static function table(Table $table): Table
{
return $table
->columns([
// ...
])
->bulkActions([
BanBulkAction::make(),
]);
}
#Unban Bulk
To be able to bulk unban a resource simply add the UnbanBulk action:
use Filament\Tables\Table;
use Gerenuk\FilamentBanhammer\Resources\Actions\UnbanBulkAction;
public static function table(Table $table): Table
{
return $table
->columns([
// ...
])
->bulkActions([
UnbanBulkAction::make(),
]);
}
A ban resource is included by default if you would prefer to use that instead.
#Testing
composer test
#Screenshots
#Resource

#Ban Action

#Ban Bulk Action

#Ban Modal

#Unban Action

#Unban Bulk Action

#Unban Modal

#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
- Based on laravel-banhammer from mchev
- Kieran Proctor
- All Contributors
#License
The MIT License (MIT). Please see License File for more information.
The author
From the same author
Featured Plugins
A selection of plugins curated by the Filament team
Custom Dashboards
Let your users build and share their own dashboards with a drag-and-drop interface. Define your data sources in PHP and let them do the rest.
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
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