承接 shuvroroy/nova-tabs 相关项目开发

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

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

shuvroroy/nova-tabs

Composer 安装命令:

composer require shuvroroy/nova-tabs

包简介

A tool for Laravel Nova which allows you to create tabs in your resource detail & form page.

关键字:

README 文档

README

PHP Version Require Latest Stable Version Total Downloads License

This package will help you to create tabs in your resource detail & form page.

Screenshot 2023-05-24 at 7 56 19 PM

Support For This Project

Buy Me A Coffee

Requirements

  • PHP (^8.1 or higher)
  • Laravel Nova (^4.12 or higher)

Installation

Require the package with composer

composer require shuvroroy/nova-tabs

Usage

Tabs Panel

You can group fields of a resource into tabs.

<?php

use App\Nova\Resource;
use Laravel\Nova\Fields\Avatar;
use Laravel\Nova\Fields\HasMany;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Line;
use Laravel\Nova\Fields\Stack;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\Trix;
use Laravel\Nova\Http\Requests\NovaRequest;
use ShuvroRoy\NovaTabs\Tab;
use ShuvroRoy\NovaTabs\Tabs;
use ShuvroRoy\NovaTabs\Traits\HasActionsInTabs;
use ShuvroRoy\NovaTabs\Traits\HasTabs;

class User extends Resource
{
    use HasTabs, HasActionsInTabs;

    public function fields(Request $request)
    {
        return [
            Tabs::make('Author', [
                Tab::make(__('Author Details'), [
                    ID::make()->sortable(),

                    Avatar::make(__('Photo'), 'photo')
                        ->disk('public')
                        ->indexWidth(50)
                        ->detailWidth(200)
                        ->squared()
                        ->disableDownload()
                        ->showOnPreview(),

                    Stack::make('Name', [
                        Line::make(__('Name'), 'name')
                            ->asHeading(),
                        Line::make(__('Email'), 'email')
                            ->asSmall()
                    ])->onlyOnIndex(),

                    Text::make(__('Name'), 'name')
                        ->sortable()
                        ->rules('required', 'max:255')
                        ->hideFromIndex()
                        ->showOnPreview(),

                    Text::make(__('Email'), 'email')
                        ->sortable()
                        ->rules('required', 'email', 'max:255')
                        ->creationRules('unique:authors,email')
                        ->updateRules('unique:authors,email,{{resourceId}}')
                        ->hideFromIndex()
                        ->showOnPreview(),

                    HasMany::make(__('Posts'), 'posts', Post::class),
                ])->showHeadingForRelationships(['posts']),
                
                Tab::make(__('Additional Information'), [
                    Trix::make(__('Bio'), 'bio')
                        ->alwaysShow()
                        ->showOnPreview(),

                    Text::make(__('Github Handle'), 'github_handle')
                        ->sortable()
                        ->rules('required', 'max:255')
                        ->showOnPreview(),

                    Text::make(__('Twitter Handle'), 'twitter_handle')
                        ->sortable()
                        ->rules('required', 'max:255')
                        ->showOnPreview(),
                ]),
           ]),
       ];
    }
 }

The first tab in every Tabs instance will be auto-selected.

Combine Fields and Relations in Tabs

<?php

use ShuvroRoy\NovaTabs\Tab;
use ShuvroRoy\NovaTabs\Tabs;
use ShuvroRoy\NovaTabs\Traits\HasActionsInTabs;
use ShuvroRoy\NovaTabs\Traits\HasTabs;
use Laravel\Nova\Fields\HasMany;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Text;

class User extends Resource
{
    use HasTabs, HasActionsInTabs;

    public function fields(Request $request)
    {
          return [
              Tabs::make(__('Client Custom Details'), [
                  Tab::make(__('Details'), [
                      ID::make('Id', 'id')->rules('required')->hideFromIndex(),
                      Text::make('Name', 'name'),

                      HasMany::make('Invoices', 'invoices'),
                  ])->showHeadingForRelationships(['invoices']),
              ]),
         ];
    }
}

Tabs on Edit View

Tabs are always shown on edit view as of Nova 4 for now.

Screenshot 2023-05-24 at 7 54 55 PM

Tab object

It's possible to use a Tab class instead of an array to represent your tabs.

Property Type Default Description
name string null The name of the tab, used for the slug. Defaults to the title if not set
showIf bool or Closure null If the result is truthy the tab will be shown. showIf takes priority over showUnless and if neither are set, true is assumed.
showUnless bool or Closure null If the result is falsy the tab will be shown. showIf takes priority over showUnless and if neither are set, true is assumed.
showHeadingForRelationships array array This is show a headings for individual relationship field based on array attribute value

Customization

Display more than 5 items

By default, any HasMany, BelongsToMany and MorphMany fields show 5 items in their index. You can use Nova's built-in static property $perPageViaRelationship on the respective resource to show more (or less).

Tab change Global Event

Nova Tabs emits an event upon tabs loading and the user clicking on a tab, using Nova Event Bus. Developers can listen to the event called nova-tabs-changed, with 2 parameters as payload: The tab panel name and the tab name itself.

Example of a component that subscribes to this event:

export default {
    mounted () {
        Nova.$on('nova-tabs-changed', (panel, tab) => {
            if (panel === 'Client Details' && tab === 'address') {
                this.$nextTick(() => this.map.updateSize())
            }
        })
    }
}

Credits

License

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

shuvroroy/nova-tabs 适用场景与选型建议

shuvroroy/nova-tabs 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 49.12k 次下载、GitHub Stars 达 9, 最近一次更新时间为 2023 年 05 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 49.12k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 18
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-27