PHP code example of simplestats-io / filament-plugin

1. Go to this page and download the library: Download simplestats-io/filament-plugin 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/ */

    

simplestats-io / filament-plugin example snippets


use SimpleStatsIo\FilamentPlugin\SimplestatsPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        // ...
        ->plugin(SimplestatsPlugin::make());
}

SimplestatsPlugin::make()
    ->apiToken('custom-token')                        // defaults to config/env
    ->apiUrl('https://simplestats.io/api/v1')         // defaults to config/env
    ->cacheTtl(60)                                    // cache duration in seconds
    ->navigationGroup('Analytics')                    // Filament nav group
    ->navigationLabel('Stats')                        // custom nav label
    ->navigationSort(5)                               // nav position
    ->navigationIcon('heroicon-o-chart-bar-square')   // default icon

// config/simplestats-filament.php

return [

    /*
     |--------------------------------------------------------------------------
     | SimpleStats API Credentials
     |--------------------------------------------------------------------------
     |
     | Define your API credentials here. The API URL defaults to the hosted
     | SimpleStats instance. If you are self-hosting, change it to your own
     | URL. The API token is the same one used by the Laravel client package.
     |
     */

    'api_url' => env('SIMPLESTATS_API_URL', 'https://simplestats.io/api/v1'),

    'api_token' => env('SIMPLESTATS_API_TOKEN'),

    /*
     |--------------------------------------------------------------------------
     | Cache Duration
     |--------------------------------------------------------------------------
     |
     | API responses are cached to avoid unnecessary requests on every page
     | load and Livewire re-render. Multiple widgets sharing the same filters
     | will reuse a single cached response. Set to 0 to disable caching.
     |
     */

    'cache_ttl' => 60,

];

SimplestatsPlugin::make()
    ->apiToken(config('simplestats-filament.api_token'))
    ->apiUrl('https://your-simplestats-instance.com/api/v1')
bash
php artisan vendor:publish --tag="simplestats-filament-config"