yaroslawww/nova-has-many-on-index

This package is abandoned and no longer maintained. The author suggests using the think.studio/nova-has-many-on-index package instead.

A Laravel Nova field used to display a 'Has Many' relationship on the index screen.

1.1.0 2023-09-03 13:49 UTC

This package is auto-updated.

Last update: 2023-09-03 15:06:28 UTC


README

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

A Laravel Nova field used to display a 'Has Many' relationship on the index screen.
Very focused package for display quantity and list. May slow down the display of the index page

Installation

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

Usage

\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(),

Credits

  • Think Studio