elegantly / filament-kpi
Plugin for elegantly/laravel-kpi
Fund package maintenance!
ElegantEngineeringTech
Requires
- php: ^8.2
- elegantly/laravel-kpi: ^1.1
- filament/filament: ^3.0
- spatie/laravel-package-tools: ^1.16.0
Requires (Dev)
- larastan/larastan: ^2.9
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1
- orchestra/testbench: ^9.0.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
README
This plugin allows you to create charts and stats using elegantly/laravel-kpi
like this:
use Elegantly\FilamentKpi\Widgets\KpiStat; use App\Kpis\Users\UsersCountKpi; KpiStat::kpi(UsersCountKpi::class);
class UsersChart extends KpiChart { protected static string $kpi = UsersCountKpi::class; }
Installation
You can install the package via composer:
composer require elegantly/filament-kpi
Usage
Display a Kpi Stat
namespace App\Filament\Resources\UserResource\Widgets; use Elegantly\FilamentKpi\Widgets\KpiStat; use App\Kpis\Users\UsersCountKpi; use Filament\Widgets\StatsOverviewWidget; class UsersStatsOverview extends StatsOverviewWidget { protected static ?string $pollingInterval = null; protected function getCards(): array { return [ KpiStat::kpi( definition: UsersCountKpi::class, interval: KpiInterval::Day, // (optional) default to UsersCountKpi::getSnapshotInterval() diff: true, // (optional) default to is_subclass_of(UsersCountKpi::class, HasDifference::class) ), ]; } }
Display a Kpi Chart
namespace App\Filament\Resources\UserResource\Widgets; use Elegantly\FilamentKpi\Widgets\KpiChart; use App\Kpis\Users\UsersCountKpi; class UsersChart extends KpiChart { protected static string $kpi = UsersCountKpi::class; }
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.