定制 z00f/filament-tools 二次开发

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

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

z00f/filament-tools

Composer 安装命令:

composer require z00f/filament-tools

包简介

Add a general-purpose tools page to your Filament project.

README 文档

README

You can install the package via Composer:

composer require z00f/filament-tools

Optionally, you can publish the views using

php artisan vendor:publish --tag="filament-tools-views"

Usage

This package will automatically register a new z00f\FilamentTools\Tools page in your Filament panel.

Registering a new tool

You can register a new tool by calling the Tools::register() function, providing a Closure as the only argument.

use z00f\FilamentTools\Tools;
use z00f\FilamentTools\Tool;

public function boot()
{
    Tools::register(function (Tool $tool): Tool {
        return $tool->label('Clear Cache');
    });
}

All tools require a label. If a label isn't provided, an instance of z00f\FilamentTools\Exception\ToolsException will be thrown.

The provided Closure will be executed via the container so you can type-hint any dependencies you need.

Tool forms

Each tool can contain it's own unique form. This form makes is simple to ask for input from the user and execute logic based on that input. You can provide your form's schema to the Tool::schema() method.

Tools::register(function (Tool $tool): Tool {
    return $tool
        ->label('Clear Cache')
        ->schema([
            TextInput::make('tag')
                ->nullable(),
        ]);
});

To run some logic when the form is submitted you can use the Tool::onSubmit() method, providing a Closure as the only argument. This Closure will receive an instance of z00f\FilamentTools\ToolInput. This class extends Illuminate\Support\Collection so you are free to call any existing Collection methods.

Tools::register(function (Tool $tool): Tool {
    return $tool
        ->label('Clear Cache')
        ->schema([
            TextInput::make('tag')
                ->nullable(),
        ])
        ->onSubmit(function (ToolInput $input) {
            $tag = $input->get('tag');

            // Do something cool here...
        });
});

Clearing form data on submit

By default, the state for your tool's form will be preserved between submissions.

If you would like to clear the data, you can call the ToolInput::clear() method from inside of your submit callback.

$tool->onSubmit(function (ToolInput $input) {
    // Do something with input here...

    $input->clear();
    $input->notify('Success!');
});

Rendering a custom view

You can provide a custom view to render inside of the tool by calling the Tool::view() method.

Tools::register(function (Tool $tool): Tool {
    return $tool
        ->label('Clear Cache')
        ->view('tools.clear-cache');
});

Customising the column span

Each row on the tools page operates on a 12-column grid. The default width for a tool is 3 columns.

If you would like to customise the width of your tool, you can use the Tool::columnSpan() method.

Tools::register(function (Tool $tool): Tool {
    return $tool
        ->label('Clear Cache')
        ->columnSpan(6);
});

Authorization

By default, all users will be able to access the Tools page. If you would like to customise this behaviour and restrict access to certain users, you can use the Tools::can() method.

public function boot()
{
    Tools::can(function (User $user): bool {
        return $user->role === Role::Admin;
    });
}

If this callback returns false, the navigation items will not be registered and anybody trying to access the route directly will receive a 403 response.

Testing

composer test

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.

z00f/filament-tools 适用场景与选型建议

z00f/filament-tools 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 06 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 14
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-06-26