Skip to content

dev-think-one/nova-has-many-on-index

Repository files navigation

Laravel Nova 'Has Many' on index

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published