定制 armincms/nova-tab 二次开发

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

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

armincms/nova-tab

Composer 安装命令:

composer require armincms/nova-tab

包简介

A Laravel Nova tool.

README 文档

README

Field's Grouping by the tab.

Table of Contents

Install

composer require armincms/nova-tab

Quick Start

First create your tab like follow.

Tab::make('tab-name', [
  'first-group-name' => 'First Group Label',
  'second-group-name' => 'Second Group Label',
  'fourth-group' => [
    // group fields
  ],
  'fifth-group' => function() {
    return [
      // group fields
    ];
  }
])->fullwidth();

Then, to insert each field into the created tab; pass the name and the group name into the withTab macro method.for example:

  Text::make('Name')->withTab('tab-name', 'first-group-name');
  Text::make('Gender')->withTab('tab-name', 'second-group-name');

Usage

First create your tab like follow. Then; for define tab field's, you can use the group method.

Tab::make('tab-name', function($tab) {

    // pass fields by callback
    $tab->group('first-tab-name', function($group) {  
      return [

        // define your tab fields

      ];
    });
    
    // pass fields by array
    // active your tab by `active` method
    $tab->group('active-tab', [ 

        // define your tab fields

    ])->active();

    // custom label tab
    $tab->group('custom-label-tab', function($group) {  
      // or inside the group
      $group->label('My Custom Label');
      
      return [

        // define your tab fields

      ];
    })->label('My Custom Label');
  
  // full width tab by call `fullwidth` method
})->fullwidth();

Ative Tab:

By default we'll active the first tab. if you want customize the active tab, it's availabe by call the active method on the tab group.

Tab Label

It's possible to customize the tab label's by passing the label string through the label method on the group.

Full Width Tab

If you want jsutify the tab for fill screen; you can call fullWidth method on the Tab::class

Attention 1: you can add any field and relation-field into the tab.

Attention 2: it's impossible to add Panel into the tab.

Attention 3: It's possible to add the tab into the Panel.

  • base example:
    use Armincms\Tab\Tab;    



    /**
     * Get the fields displayed by the resource.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function fields(Request $request)
    {
        return Tab::make('general', function($tab) {
          $tab->group('general', [
              ID::make()->sortable(),  

              Select::make('Tag')->options(function() {
                  return ['*' => 'all'];
              })->default('*'),     
          ])->label(__('General')); 

          $tab->group('SEO', [ 
              Text::make('Title'), 
          ])->active();  

          $tab->group('Relations', [
              MorphToMany::make('Tag'),  
          ])->label('Relations');  
        })->toArray(); 
    }
  • Fullwidth tab example:
    use Armincms\Tab\Tab;    



    /**
     * Get the fields displayed by the resource.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function fields(Request $request)
    {
        return Tab::make('general', function($tab) {
          $tab->group('general', [$this, 'generalFields'])->label(__('General')); 

          $tab->group('SEO', [ 
              Text::make('Title'), 
          ])->active();  

          $tab->group('Relations', [
              MorphToMany::make('Tag'),  
          ])->label('Relations');  
        })->fullwidth()->toArray(); 
    }

    public function generalFields() 
    {
      return $this->merge([
        ID::make()->sortable(),   
        Select::make('Tag')->options(function() {
            return ['*' => 'all'];
        })->default('*'),
      ]);
    }

Multiple Tabs

You can add multiple tab into form and detail page. for this situation; just needs making different name for different tabs.

Attention 1: You can't add same relation-field in different tabs.it just work with one of them.


    use Armincms\Tab\Tab;    



    /**
     * Get the fields displayed by the resource.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function fields(Request $request)
    {
        return [       
            Tab::make('first-tab', function($tab) {
                $tab->group('general', [$this, 'generalFields'])->label(__('General')); 

                $tab->group('SEO', [ 
                    Text::make('Title'), 
                ])->active();  

                $tab->group('Relations', [
                    MorphToMany::make('Tag'),  
                ])->label('Relations');  
            }),  
            Tab::make('second-tab', function($tab) {
                $tab->group('general', [
                    ID::make()->sortable(),  

                    Select::make('Tag')->options(function() {
                        return ['*' => 'all'];
                    })->default('*'),     
                ])->label(__('General')); 

                $tab->group('SEO', [ 
                    Text::make('Title'), 
                ])->active();  

                $tab->group('Relations', [
                    MorphToMany::make('Category'),  
                ])->label('Relations');  
            }),    
        ]; 
    }

    
    public function generalFields() 
    {
      return $this->merge([
        ID::make()->sortable(),   
        Select::make('Tag')->options(function() {
            return ['*' => 'all'];
        })->default('*'),
      ]);
    }

Using With Panel

You can add tab into Panel but you never can add Panel into tab.


    use Armincms\Tab\Tab;    



    /**
     * Get the fields displayed by the resource.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function fields(Request $request)
    {
        return [     
            new Panel('First Panel', [  
                Tab::make('general', function($tab) {
                    $tab->group('general', [
                        ID::make()->sortable(),  

                        Select::make('Tag')->options(function() {
                            return ['*' => 'all'];
                        })->default('*'),     
                    ])->label(__('General')); 

                    $tab->group('SEO', [ 
                        Text::make('Title'), 
                    ])->active();  

                    $tab->group('Relations', [
                        MorphToMany::make('Tag'),  
                    ])->label('Relations');  
                }), 
            ]), 
    }

Relations


    use Armincms\Tab\Tab;    



    /**
     * Get the fields displayed by the resource.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function fields(Request $request)
    {
        return [     
            new Panel('My Panel', [  
                Tab::make('general', function($tab) {
                    $tab->group('Author', [
                        ID::make()->sortable(),  

                        BelogsTo::make('User'),   
                    ])->label(__('General'));  

                    $tab->group('Relations', [
                        MorphToMany::make('Tag'),  
                    ])->label('Relations');  
                }), 
            ])   
        ]; 
    }

Missed Tabs

If some fields missing in the tab, with macro method withTab you can add the missed field into the tab. like following example:

  Text::make('FieldName')->withTab('tab-name', 'group-name')

armincms/nova-tab 适用场景与选型建议

armincms/nova-tab 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 73.4k 次下载、GitHub Stars 达 8, 最近一次更新时间为 2019 年 10 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 armincms/nova-tab 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 73.4k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 24
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-10-21