承接 bezhansalleh/filament-panel-switch 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

bezhansalleh/filament-panel-switch

Composer 安装命令:

composer require bezhansalleh/filament-panel-switch

包简介

Easily Switch between your Filament Panels

README 文档

README

Panel Switch

FILAMENT 4.x FILAMENT 5.x Packagist Code Style Passing Downloads

Panel Switch

The Panel Switch Plugin for Filament offers a robust and customizable component for switching between panels in applications built with FilamentPHP.

Demo Demo Demo

Table Of Contents

Compatibility

Package Version Filament Version
1.x 3.x
2.x 4.x & 5.x
3.x - current 4.x & 5.x

Installation

You can install the package via composer:

composer require bezhansalleh/filament-panel-switch

Important

The plugin follows Filament's theming rules. So, to use the plugin create a custom theme if you haven't already, and add the following line to your theme.css file:

@source '../../../../vendor/bezhansalleh/filament-panel-switch/resources/views/**/*.blade.php';

Now build your theme using:

npm run build

Upon installation, the Plugin seamlessly integrates with Filament without any further setup. Though the plugin works out-of-the-box, it's designed for customization. Delve into the Configuration section below for detailed customization options.

Configuration

Start your custom configuration using the configureUsing method in your service provider's boot method:

use BezhanSalleh\PanelSwitch\PanelSwitch;

PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) {
    // Custom configurations go here
});

Panel Access & Navigation

The panel switch is automatically visible when the authenticated user has access to two or more panels. Panel access is determined via the canAccessPanel method on your User model — no additional configuration needed. Panels the user cannot access are automatically hidden from the switch.

To further limit which panels appear in the switch, use the panels() method:

PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) {
    $panelSwitch->panels([
        'admin',
        'dev',
        'app'
    ]);
});

The panels() method also accepts a closure that returns an array of panel ids. This is useful when you want to dynamically determine the panels that will be listed. The plugin will also validate the panels to ensure that they are valid filament panels. If any of the panels provided are invalid, the plugin will throw an InvalidArgumentException.

Design or Style

The plugin supports two design styles:

  • Modern (default) — Uses Filament's Modal Blade component. You can customize the modal heading, width, or use a slide-over:

    PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) {
        $panelSwitch
            ->modalHeading('Available Panels')
            ->modalWidth('sm')
            ->slideOver();
    });
  • Simple — A dropdown list for switching panels directly:

    PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) {
        $panelSwitch->simple();
    });

For full control over the look and feel, you can publish the views and make your own adjustments:

php artisan vendor:publish --tag="filament-panel-switch-views"

Labels

Provide custom labels for each panel. The keys should be valid panel IDs, and values can be strings or translatable strings:

PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) {
    $panelSwitch
        ->labels([
            'admin' => 'Custom Admin Label',
            'general_manager' => __('General Manager')
        ]);
});

Icons

Define icons for each panel using the icons() method. The keys should be valid panel IDs:

PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) {    
    $panelSwitch->icons([
        'admin' => 'heroicon-o-square-2-stack',
        'app' => 'heroicon-o-star',
    ]);
});

For images instead of icons, set the asImage parameter to true:

PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) {    
    $panelSwitch->icons([
        'admin' => 'https://example.com/admin.jpg',
        'app' => 'https://example.com/app.jpg',
    ], asImage: true);
});

Use iconSize() to customize the size (default 128px). The value is multiplied by 4:

PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) {
    $panelSwitch->iconSize(32); // 128px
});

Sort Order

By default panels are listed in registration order, or in the order provided via panels(). Use sort() to sort alphabetically:

PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) {
    $panelSwitch
        ->panels(['admin', 'dev', 'app'])
        ->sort();         // ascending: ['admin', 'app', 'dev']
        // ->sort('desc') // descending: ['dev', 'app', 'admin']
});

Placement

By default the panel switch is rendered via the panels::global-search.before render hook. You can change this to any available Filament Render Hook:

PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) {
    $panelSwitch->renderHook('panels::global-search.after');
});

Full Example

use BezhanSalleh\PanelSwitch\PanelSwitch;

PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) {
    $panelSwitch
        ->panels(['admin', 'app', 'dev'])
        ->heading('Available Panels')
        ->modalWidth('sm')
        ->slideOver()
        ->icons([
            'admin' => 'heroicon-o-square-2-stack',
            'app' => 'heroicon-o-star',
        ])
        ->iconSize(16)
        ->labels([
            'admin' => 'Admin Panel',
            'app' => 'SaaS Application'
        ]);
        
});

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

If you want to contribute to this packages, you may want to test it in a real Filament project:

  • Fork this repository to your GitHub account.
  • Create a Filament app locally.
  • Clone your fork in your Filament app's root directory.
  • In the /filament-panel-switch directory, create a branch for your fix, e.g. fix/error-message.

Install the packages in your app's composer.json:

"require": {
    "bezhansalleh/filament-panel-switch": "dev-fix/error-message as main-dev",
},
"repositories": [
    {
        "type": "path",
        "url": "filament-panel-switch"
    }
]

Now, run composer update.

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.

bezhansalleh/filament-panel-switch 适用场景与选型建议

bezhansalleh/filament-panel-switch 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 403.95k 次下载、GitHub Stars 达 161, 最近一次更新时间为 2023 年 08 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 161
  • Watchers: 4
  • Forks: 30
  • 开发语言: Blade

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-04