Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Filament Simple Stats

Filament Simple Stats Laravel Package

spatie/filament-simple-stats

Opinionated prebuilt stat widgets for Filament dashboards. Quickly add counts and sums with ready-made Stat widgets powered by Flowframe/laravel-trend, including last 30 days trends (daily/weekly) for models and fields.

View on GitHub
Deep Wiki
Context7

Opinionated prebuilt stat widgets to quickly add to your Filament dashboards.

Frequently asked questions about Filament Simple Stats
How do I install spatie/filament-simple-stats in a Laravel 13 project?
Run `composer require spatie/filament-simple-stats` in your project directory. The package is officially compatible with Laravel 13 and requires no additional configuration beyond Filament’s setup. Ensure Filament v3+ is installed if targeting newer features.
Can I use these widgets with Filament v2 or only v3?
The package works with both Filament v2 and v3, but some features may align better with v3’s API. Test thoroughly if migrating from v2, as widget registration methods or caching hooks might differ. Check the [Filament changelog](https://filamentphp.com/docs/3.x/upgrading) for breaking changes.
What Laravel versions does spatie/filament-simple-stats support?
The package is officially supported on Laravel 13+. If you’re on Laravel 12 or below, upgrade first (`composer require laravel/framework:^13.0`) to avoid compatibility risks. Test your app post-upgrade, as Laravel 13 introduces breaking changes like model observer updates.
How do I create a stat widget for a custom field sum (e.g., total revenue)?
Use `SimpleStat::make(Model::class)->last30Days()->dailySum('field_name')` in your widget’s `getStats()` method. Replace `Model` with your Eloquent model and `field_name` with the column (e.g., `earnings`). For non-standard aggregations, consider extending the bundled `laravel-trend` logic or forking the package.
Does this package work with PostgreSQL or only MySQL?
Yes, it’s database-agnostic and supports any Laravel-supported database, including PostgreSQL. For trend queries, PostgreSQL’s `date_trunc` or MySQL’s `DATE_FORMAT` can optimize performance. The package abstracts these differences, but complex aggregations may need manual tuning.
Will inlining laravel-trend break my existing trend-based queries?
Unlikely, but test thoroughly if you rely on `flowframe/laravel-trend`’s public methods. The inlined version maintains core functionality, but internal API changes could affect custom logic. Check the [migration guide](https://github.com/spatie/filament-simple-stats#migration) for known issues.
How do I cache stat widgets for better performance?
Use Filament’s built-in caching by defining a `cacheFor` method in your widget class (e.g., `public function cacheFor(): ?int { return 60; }`). The package respects Filament’s caching layer, but ensure TTLs align with your data freshness needs, especially for high-traffic dashboards.
Are there alternatives to spatie/filament-simple-stats for Filament stats?
Yes, consider `filament/spatie-laravel-resource-stats` for resource-specific stats or `filament/stats` for basic widgets. However, this package uniquely combines `laravel-trend` for time-series data (e.g., 30-day trends) with Filament’s UI, making it ideal for analytics-heavy dashboards.
Can I customize the appearance of the stat widgets beyond the default styles?
The package is opinionated but allows overrides. Extend the `SimpleStat` class or use Filament’s widget styling hooks (e.g., CSS classes in `getClasses()`). For non-standard visualizations, fork the package or use Filament’s native `Stat` widget as a base.
How do I handle large datasets (e.g., millions of records) with trend queries?
Optimize trend queries by adding database indexes on date fields or using `selectRaw` for complex aggregations. The inlined `laravel-trend` supports chunking and query caching. For PostgreSQL, leverage `date_trunc` for faster date-based grouping. Monitor query performance with Laravel Debugbar.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport