widiu7omo/filament-bandel

Banned Model with Filament Bandel

v2.0.0 2023-09-27 02:02 UTC

This package is auto-updated.

Last update: 2024-04-27 03:20:25 UTC


README

This code forked from - Truong Thanh Tung Filament Ban

Introduction

We are using laravel-ban by cybercog on the background.

single_ban_user bulk_ban_user

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.