PHP code example of nova-bi / nova-dashboard-manager

1. Go to this page and download the library: Download nova-bi/nova-dashboard-manager 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/ */

    

nova-bi / nova-dashboard-manager example snippets


use DigitalCreative\NovaDashboard\NovaDashboard;
use NovaBi\NovaDashboardManager\DashboardManager;


public function tools()
{
    return [
        new DashboardManager(), // must be loaded first !!!
        new NovaDashboard(),
    ];
}


    // CollapsibleResourceManager
    use DigitalCreative\CollapsibleResourceManager\CollapsibleResourceManager;
    use DigitalCreative\CollapsibleResourceManager\Resources\Group;
    use DigitalCreative\CollapsibleResourceManager\Resources\NovaResource;
    use DigitalCreative\CollapsibleResourceManager\Resources\RawResource;
    use DigitalCreative\CollapsibleResourceManager\Resources\TopLevelResource;
    
    // Dashboard
    use DigitalCreative\NovaDashboard\NovaDashboard;
    use NovaBi\NovaDashboardManager\DashboardManager;
    use NovaBi\NovaDashboardManager\DashboardResource;
    use NovaBi\NovaDashboardManager\Nova\DashboardConfiguration;
    use NovaBi\NovaDashboardManager\Nova\Datafilter;
    use NovaBi\NovaDashboardManager\Nova\Datawidget;

    /**
     * Get the tools that should be listed in the Nova sidebar.
     *
     * @return array
     */
    public function tools()
    {
        $analyticsDataboards = [];
        $dashboards = (new DashboardManager)->dashboards();

        foreach ($dashboards as $dboard) {
            $analyticsDataboards[] = DashboardResource::make($dboard)->label($dboard->resourceLabel())->icon(faIcon('cog'));
        }

        return [
            new DashboardManager(), // must be loaded first !!!
            new NovaDashboard(), // must be loaded as well

            new CollapsibleResourceManager([
                'navigation' => [
                    TopLevelResource::make([
                        'label' => 'Databoards',
                        'icon' => '<svg fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24" stroke="currentColor" class="sidebar-icon"><path d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"></path></svg>',
                        'resources' => $analyticsDataboards
                    ]),
                    TopLevelResource::make([
                        'label' => 'Admin',
                        'icon' => '<svg fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24" stroke="currentColor"><path d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"></path><path d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path></svg>',
                        'resources' => [
                            \App\Nova\User::class,
                            Group::make([
                                    'label' => 'Dashboard Configuration',
                                    'expanded' => false,
                                    'icon' => '',
                                    'resources' =>
                                        [
                                            NovaResource::make( DashboardConfiguration::class)->index(),
                                            NovaResource::make( Datafilter::class)->index(),
                                            NovaResource::make( Datawidget::class)->index(),
                                        ]
                                ]
                            )
                        ]
                    ]),
                ]
            ])
        ];
    }