PHP code example of yaroslawww / nova-has-many-on-index

1. Go to this page and download the library: Download yaroslawww/nova-has-many-on-index library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yaroslawww / nova-has-many-on-index example snippets


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