定制 gerenuk/filament-banhammer 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

gerenuk/filament-banhammer

Composer 安装命令:

composer require gerenuk/filament-banhammer

包简介

This package adds model banning functionality to filament

README 文档

README

Project banner

Filament Banhammer

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads Licence

This package uses mchev/banhammer to add model banning functionality to filament.

Table of Contents

  1. Introduction
  2. Version Compatibility
  3. Installation
  4. Usage
  5. Testing
  6. Screenshots
  7. Changelog
  8. Contributing
  9. Security Vulnerabilities
  10. Credits
  11. 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 Resource

Ban Action

Ban Action

Ban Bulk Action

Ban Bulk Action

Ban Modal

Ban Modal

Unban Action

Unban Action

Unban Bulk Action

Unban Bulk Action

Unban Modal

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

License

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

gerenuk/filament-banhammer 适用场景与选型建议

gerenuk/filament-banhammer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.93k 次下载、GitHub Stars 达 12, 最近一次更新时间为 2024 年 05 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「filament」 「Gerenuk」 「banhammer」 「filament-banhammer」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 gerenuk/filament-banhammer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 gerenuk/filament-banhammer 我们能提供哪些服务?
定制开发 / 二次开发

基于 gerenuk/filament-banhammer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 12
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-05-28