定制 awcodes/filament-quick-create 二次开发

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

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

awcodes/filament-quick-create

Composer 安装命令:

composer require awcodes/filament-quick-create

包简介

Plugin for Filament Admin that adds a dropdown menu to the header to quickly create new items.

README 文档

README

Plugin for Filament Panels that adds a dropdown menu to the header to quickly create new items from anywhere in your app.

Latest Version MIT Licensed Total Downloads GitHub Repo stars

Compatibility

Package Version Filament Version
2.x 2.x
3.x 3.x
4.x 4.x
5.x 5.x

Installation

Install the package via composer

composer require awcodes/filament-quick-create

Important

If you have not set up a custom theme and are using Filament Panels follow the instructions in the Filament Docs first.

After setting up a custom theme add the plugin's views to your theme css file.

@source '../../../../vendor/awcodes/filament-quick-create/resources/**/*.blade.php';

Usage

By default, Quick Create will use all resources that are registered with current Filament context. All resources will follow the authorization used by Filament, meaning that if a user doesn't have permission to create a record it will not be listed in the dropdown.

Registering the plugin

use Awcodes\QuickCreate\QuickCreatePlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            QuickCreatePlugin::make(),
        ])
}

Warning Excludes and includes are not meant to work together. You should use one or the other, but not both.

Excluding Resources

Excluding resources will filter them out of the registered resources to prevent them from displaying in the dropdown.

use Awcodes\QuickCreate\QuickCreatePlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            QuickCreatePlugin::make()
                ->excludes([
                    \App\Filament\Resources\UserResource::class,
                ]),
        ])
}

Including Resources

Sometimes, it might be easier to only include some resources instead of filtering them out. For instance, you have 30 resources but only want to display 3 to 4 in the dropdown.

use Awcodes\QuickCreate\QuickCreatePlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            QuickCreatePlugin::make()
                ->includes([
                    \App\Filament\Resources\UserResource::class,
                ]),
        ])
}

Sorting

By default, Quick Create will sort all the displayed options in descending order by Label. This can be disabled should you choose. In which case they will be displayed in the order they are registered with Filament.

use Awcodes\QuickCreate\QuickCreatePlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            QuickCreatePlugin::make()
                ->sort(false),
        ])
}

Sorting by resource navigation

By default, Quick Create will sort all the displayed options by Label. This can be changed to resource navigation sort should you choose. In which case they will be displayed in the order they are displayed in the navigation.

use Awcodes\QuickCreate\QuickCreatePlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            QuickCreatePlugin::make()
                ->sortBy('navigation'),
        ])
}

Registering keybindings

You can attach keyboard shortcuts to trigger the Quick Create dropdown. To configure these, pass the keyBindings() method to the configuration:

use Awcodes\QuickCreate\QuickCreatePlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            QuickCreatePlugin::make()
                ->keyBindings(['command+shift+a', 'ctrl+shift+a']),
        ])
}

Create Another

By default, the ability to create another record will respect the settings of your 'create record' or 'list records' create action. This can be overridden to either enable or disable it for all resources with the createAnother() method.

use Awcodes\QuickCreate\QuickCreatePlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            QuickCreatePlugin::make()
                ->createAnother(false),
        ])
}

Appearance

Rounded

By default, the Quick Create button will be fully rounded if you would like to have a more square button you can disable the rounding with the rounded() method.

use Awcodes\QuickCreate\QuickCreatePlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            QuickCreatePlugin::make()
                ->rounded(false),
        ])
}

Hiding Icons

If you prefer to not show icons for the items in the menu you can disable them with the hiddenIcons() method.

use Awcodes\QuickCreate\QuickCreatePlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            QuickCreatePlugin::make()
                ->hiddenIcons(),
        ])
}

Setting a label

If you prefer to show a label with the plus icon you can set it using the label() method and passing your label to it.

use Awcodes\QuickCreate\QuickCreatePlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            QuickCreatePlugin::make()
                ->label('New'),
        ])
}

Slide Overs

By default, Quick Create will render simple resources in a standard modal. If you would like to render them in a slide over instead you may use the slideOver() modifier to do so.

use Awcodes\QuickCreate\QuickCreatePlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            QuickCreatePlugin::make()
                ->slideOver(),
        ])
}

Hiding Quick Create

By default, Quick Create is visible if there are registered resources. If you would like to hide it you may use the hidden() modifier to do so.

use Awcodes\QuickCreate\QuickCreatePlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            QuickCreatePlugin::make()
                ->hidden(fn() => Filament::getTenant()->requiresOnboarding()),
        ])
}

Render Plugin on a Custom Panel Hook

By default, Quick Create plugin renders using 'panels::user-menu.before' Filament Panel Render Hook. If you would like to customize this to render at a different render hook, you may use the renderUsingHook(string $panelHook) modifier to do so. You may read about the available Render Hooks in Filament PHP here

use Awcodes\QuickCreate\QuickCreatePlugin;
use Filament\View\PanelsRenderHook;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            QuickCreatePlugin::make()
                ->renderUsingHook(PanelsRenderHook::SIDEBAR_NAV_END),
        ])
}

Forcing all resources to use modals

Quick create will automatically determine if it should redirect to a create page or to show the form in a modal based on the resource. If you prefer to force all items to be show in a modal you can do so with the alwaysShowModal() modifier.

use Awcodes\QuickCreate\QuickCreatePlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            QuickCreatePlugin::make()
                ->alwaysShowModal(),
        ])
}

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.

awcodes/filament-quick-create 适用场景与选型建议

awcodes/filament-quick-create 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 210.47k 次下载、GitHub Stars 达 248, 最近一次更新时间为 2022 年 07 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 248
  • Watchers: 3
  • Forks: 37
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-07-06