PHP code example of gsferro / filament-stat-plus-easy

1. Go to this page and download the library: Download gsferro/filament-stat-plus-easy 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/ */

    

gsferro / filament-stat-plus-easy example snippets


use Gsferro\FilamentStatPlusEasy\Widgets\StatPlus;

protected function getStats(): array
{
    return [
        StatPlus::make('Projetos em andamento', Projeto::emAndamento()->count())
            ->icon('heroicon-o-folder-open'),

        StatPlus::make('SLA estourado', Ticket::atrasados()->count())
            ->icon('heroicon-o-exclamation-triangle')
            ->iconColor('danger'),
    ];
}

use Gsferro\FilamentStatPlusEasy\FilamentStatPlusEasyPlugin;

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

StatPlus::make('Entidades', 42)
    ->icon('heroicon-o-building-library');

// os dois na cor do ícone
StatPlus::make('Entidades', 42)->icon('heroicon-o-building-library')->iconColor('success');

// só o ícone, sem borda
StatPlus::make('Entidades', 42)->icon('heroicon-o-building-library')->accentColor(false);

// ícone numa cor, borda em outra
StatPlus::make('SLA', 3)->icon('heroicon-o-clock')->iconColor('gray')->accentColor('danger');

// só a borda, sem ícone
StatPlus::make('Receita', 'R$ 1,2M')->accentColor('success');

StatPlus::make('Projetos', 128)
    ->icon('heroicon-o-folder-open')
    ->description('12% neste mês')
    ->descriptionIcon('heroicon-m-arrow-trending-up')
    ->chart([7, 12, 9, 14, 18, 22])
    ->url(ProjetoResource::getUrl())
    ->extraAttributes(['class' => 'minha-classe']);

StatPlus::make('Receita', 1250000)
    ->icon('heroicon-o-banknotes')
    ->format(['style' => 'currency', 'currency' => 'BRL'])
    ->duration(1500);

use Filament\Widgets\StatsOverviewWidget\Stat;
use Gsferro\FilamentStatPlusEasy\Concerns\HasStatPlus;

class MeuStat extends Stat
{
    use HasStatPlus;
}

use Filament\Widgets\StatsOverviewWidget;
use Gsferro\FilamentStatPlusEasy\Concerns\HasStatPlusPlaceholder;

class VisaoGeralStats extends StatsOverviewWidget
{
    use HasStatPlusPlaceholder;

    protected static bool $isLazy = true;
}

// outra quantidade de cards
protected function getPlaceholderStatsCount(): int
{
    return 3;
}

// widget misto (alguns stats com acento, outros não): lê os stats reais e
// espelha card a card — custa as queries no placeholder
protected bool $placeholderReadsStats = true;

->plugin(
    FilamentStatPlusEasyPlugin::make()
        ->iconColor('info')   // cor padrão do ícone quando o stat não define
        ->accent(false)       // borda desligada por padrão neste painel
)

// config/filament-stat-plus-easy.php
return [
    'icon_color' => 'primary',
    'accent' => true,
];

// ou só neste card
StatPlus::make('Projetos', 12)
    ->icon('heroicon-o-folder-open')
    ->extraAttributes(['style' => '--stat-plus-border-width: 8px']);
bash
php artisan vendor:publish --tag=filament-stat-plus-easy-config