PHP code example of sergeybruhin / laravel-analytics-nova-tool

1. Go to this page and download the library: Download sergeybruhin/laravel-analytics-nova-tool 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/ */

    

sergeybruhin / laravel-analytics-nova-tool example snippets


// app/Providers/NovaServiceProvider.php
use SergeyBruhin\NovaAnalytics\Dashboards\Analytics as AnalyticsDashboard;
use SergeyBruhin\NovaAnalytics\NovaAnalyticsTool;
use SergeyBruhin\NovaAnalytics\Resources\{Visitor, Session, Pageview, Event};

public function dashboards()
{
    return [
        (new AnalyticsDashboard)->canSee(fn ($request) => $request->user()?->isAdmin() ?? false),
    ];
}

public function tools()
{
    return [
        (new NovaAnalyticsTool)->canSee(fn ($request) => $request->user()?->isAdmin() ?? false),
    ];
}

// wherever your app registers Nova resources, e.g. Nova::resources([...]):
Nova::resources([Visitor::class, Session::class, Pageview::class, Event::class]);