think.studio / nova-has-many-on-index
A Laravel Nova field used to display a 'Has Many' relationship on the index screen.
1.1.0
2023-09-03 13:49 UTC
Requires
- php: ^8.1
- laravel/nova: ^4.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.20
- orchestra/testbench: ^8.5
- phpunit/phpunit: ^10.2
- psalm/plugin-laravel: ^2.8
- vimeo/psalm: ^5.13
README
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(),