承接 lupennat/nova-expandable-many 相关项目开发

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

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

lupennat/nova-expandable-many

Composer 安装命令:

composer require lupennat/nova-expandable-many

包简介

Laravel Nova - Expandable Many

关键字:

README 文档

README

  1. Requirements
  2. Installation
  3. Usage
  4. Changelog
  5. Credits

Requirements

  • php: ^7.4 | ^8
  • laravel/nova: ^4

Installation

composer require lupennat/nova-expandable-many:^3.0
NOVA PACKAGE
<4.29.5 1.x
<4.32.6 2.x
>=4.32.6 3.x

Usage

Register Trait HasExpandableMany globally on Resources.

the Trait include an override of indexFields method, it call method withoutListableFieldsNotExpandable instead of withoutListableFields on FieldCollection; if you already register a custom ovveride of indexFields you can do it manually without using provided trait.

ExpandableMany Package automatically enable a new method expandable for all Many Relationship Fields:

  • BelongsToMany
  • HasMany
  • HasManyThrough
  • MorphedByMany
  • MorphMany
  • MorphToMany

The relation table (without any custom actions and lenses) will be displayed as a collapsable row on the index page.

use Laravel\Nova\Fields\HasMany;
use Laravel\Nova\Http\Requests\NovaRequest;

class User extends Resource
{

   use Lupennat\ExpandableMany\HasExpandableMany;

    public function fields(Request $request)
    {
        return [
            HasMany::make('User Post', 'posts', Post::class)->expandable();
        ];
    }
}

By Default expandable use Show and Hide as labels, you can change labels using meta

    HasMany::make('User Post', 'posts', Post::class)->expandable()
        ->withMeta([
            'expandableShowLabel' => 'Custom Show',
            'expandableHideLabel' => 'Custom Hide',
        ])

you can also define a custom HTML using

    HasMany::make('User Post', 'posts', Post::class)->expandable()
        ->withMeta([
            'expandableShowHtml' => '<strong>Custom Show Html</strong>',
            'expandableHideHtml' => '<strong>Custom Hide Html</strong>',
        ])

if both custom label and HTML are defined, HTML will be used

By Default expandable do not store on browser history any status, you can change it using meta

    HasMany::make('User Post', 'posts', Post::class)->expandable()
        ->withMeta([
            // 'expandableStoreStatus' => 'full', // will store status also for relationships
            'expandableStoreStatus' => 'accordion', // will store status only for accordion
            'expandableStoreStatus' => '', // will not store any status
        ])

Expandable can be skipped and an empty field is shown (by Default is false)

    HasMany::make('User Post', 'posts', Post::class)->expandable()
        ->withMeta([
            'expandableSkip' => true,
            'expandableSkipLabel' => '', // default is '—'
        ])

Expandable can disable standard actions (By Default is enabled)

    HasMany::make('User Post', 'posts', Post::class)->expandable()
        ->withMeta([
            'expandableUseStandardActions' => false, // disable create/edit/view/delete/restore
        ])

Display Callback

Expandable Many will resolve a display callback foreach resource, you can use it to manipulate meta attributes dinamically.

    HasMany::make('User Post', 'posts', Post::class)
        ->expandable(function(HasMany $field, $resource) {
            $resource->loadCount('posts');
            $field->withMeta([
                'expandableShowLabel' => 'Show ' . $resource->posts_count,
                'expandableSkip' => $resource->posts_count === 0
            ]);
        })

By Default Expandable do not resolve relations, accessing a relationAttribute through the $resource will execute a query against database to load all related models.

Lens

If you want to use Expandable Many inside a Lens, you need to register also the trait HasExpandableManyLens inside your Lens.

use Laravel\Nova\Fields\HasMany;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Lenses\Lens;

class UserLens extends Lens
{
   use Lupennat\ExpandableMany\HasExpandableManyLens;

    public function fields(Request $request)
    {
        return [
            HasMany::make('User Post', 'posts', Post::class)->expandable();
        ];
    }
}

Credits

This package is based on the original idea from Nova Expandable Row

lupennat/nova-expandable-many 适用场景与选型建议

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 4
  • Watchers: 2
  • Forks: 6
  • 开发语言: Vue

其他信息

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