widiu7omo / filament-bandel
Banned Model with Filament Bandel
Installs: 30 601
Dependents: 1
Suggesters: 0
Security: 0
Stars: 12
Watchers: 1
Forks: 3
Open Issues: 0
Requires
- php: ^8.1
- cybercog/laravel-ban: ^4.8
- filament/filament: ^3.0
- illuminate/contracts: ^11.8
- spatie/laravel-package-tools: ^1.14
Requires (Dev)
- nunomaduro/collision: ^8.1
- pestphp/pest: ^2.4
- pestphp/pest-plugin-laravel: ^2.0
README
This code forked from - Truong Thanh Tung Filament Ban
Introduction
We are using laravel-ban by cybercog on the background.
Requirement
- Laravel 10
- FilamentPHP
Installation
You can install the package via composer:
composer require widiu7omo/filament-bandel
You can publish and run the migrations with:
php artisan vendor:publish --tag="filament-bandel-migrations"
php artisan migrate
ou can publish and run the translations with:
php artisan vendor:publish --tag="filament-bandel-translations"
You can publish the config file from cybercog/laravel-ban with:
php artisan vendor:publish --tag="ban-config"
Prepare Bannable model
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; }
Prepare bannable model database table
Bannable model must have nullable timestamp
column named banned_at
. This value used as flag and simplify checks if
user was banned. If you are trying to make default Laravel User model to be bannable you can use example below.
Register Ban Actions in Filament Resource
Register BanAction
and UnbanAction
actions inside your Model's Resource.
public static function table(Table $table): Table { return $table ->actions([ // ...rest, \Widiu7omo\FilamentBandel\Actions\BanAction::make(), \Widiu7omo\FilamentBandel\Actions\UnbanAction::make() ]); }
Register Bulk Un/Ban Actions in Filament Resource
Register BanBulkAction
and UnbanBulkAction
actions inside your Model's Resource.
public static function table(Table $table): Table { return $table ->prependBulkActions([ // ...rest \Widiu7omo\FilamentBandel\Actions\BanBulkAction::make('banned_model'), \Widiu7omo\FilamentBandel\Actions\UnbanBulkAction::make('unbanned_model'), ]); }
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.