PHP code example of the-3labs-team / nova-google-analytics-cards

1. Go to this page and download the library: Download the-3labs-team/nova-google-analytics-cards 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/ */

    

the-3labs-team / nova-google-analytics-cards example snippets


use The3LabsTeam\NovaGoogleAnalyticsCards\Counter\ActiveUsersCounter;use The3LabsTeam\NovaGoogleAnalyticsCards\Counter\NewUsersCounter;use The3LabsTeam\NovaGoogleAnalyticsCards\Counter\PageViewsCounter;use The3LabsTeam\NovaGoogleAnalyticsCards\LineChart\PageViewLineChart;

...

(new ActiveUsersCounter())
(new NewUsersCounter())
(new PageViewsCounter())
            
(new PageViewLineChart())


use The3LabsTeam\NovaGoogleAnalyticsCards\Counter\ActiveUsersCounter;
...

(new ActiveUsersCounter(name: 'The name of the card (string)'))



/**
* Return the page path for Google Analytics
*/
public function getGaPagePathAttribute(): string
{
   return str_replace(config('app.url'), '', $this->route);
}

public function cards(NovaRequest $request)
{
    return [
        (new PageViewLineChart(articleId: $request->resourceId))->width('1/2 ')
            ->onlyOnDetail()
            ->height('dynamic'),
        (new RefClickPartition(articleId: $request->resourceId))->width('1/3')
                ->onlyOnDetail()
                ->height('dynamic'),
    ];
}
bash
php artisan vendor:publish
bash
php artisan vendor:publish