think.studio / nova-has-many-on-index

一个Laravel Nova字段,用于在索引屏幕上显示“多对多”关系。

1.1.0 2023-09-03 13:49 UTC

This package is auto-updated.

Last update: 2024-09-03 17:44:08 UTC


README

Packagist License Packagist Version Total Downloads Build Status Code Coverage Scrutinizer Code Quality

一个Laravel Nova字段,用于在索引屏幕上显示“多对多”关系。
一个非常专注于显示数量和列表的包。可能会减慢索引页面的显示速度

安装

composer require think.studio/nova-has-many-on-index

用法

\NovaHasManyIndex\NovaHasManyOnIndex::make(trans('cols-computed.subscriptions'), 'subscriptions_count')
        ->displayUsing(function ($val, $model) {
            return [
                'val'          => $val,
                'items'        => $model->subscriptions->map(function ($item) {
                    return [
                        'url'    => route('nova.pages.detail', [
                            'resource' => Contact::uriKey(),
                            'resourceId' => $item->getKey(),
                        ]),
                        'title' => "({$item->getKey()}) $item->name",
                        'icon' => [
                            'type' => 'trash',
                            'solid' => true,
                            'class' => 'text-red-500',
                        ],
                    ];
                })->all(),
            ];
        })
        ->sortable(),

致谢

  • Think Studio