• Bandel
  • Bandel

Bandel

Plugin information

by Danar Widi

Action Table builder Admin panel

Un/Ban model with Bannable

In the background, we are using laravel-ban by cybercog.

Support

#bandel on Discord

Views

2011

License

MIT

Documentation

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'),
]);
}