Weave 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 that combine Filament's Stat widgets with laravel-trend, so you can quickly show daily counts or sums for a model over the last 30 days with just a few lines of code.

View on GitHub
Deep Wiki
Context7

Spatie Filament Simple Stats provides opinionated, prebuilt stat widgets that you can drop straight into your Filament dashboards. It combines native Filament Stat widgets with the Flowframe/laravel-trend package, so you can display trends and totals from any Eloquent model with a single, fluent line of code.

SimpleStat::make(User::class)->last30Days()->dailyCount(),
SimpleStat::make(Purchase::class)->last30Days()->dailySum('earnings'),
  • Ready-made widgets for Filament dashboards
  • Trend charts via laravel-trend integration
  • Counts and sums over daily, monthly, or custom periods
  • Fluent API with last30Days(), dailyCount(), dailySum()
  • Customizable queries using where() and other constraints
Frequently asked questions about Filament Simple Stats
How do I install spatie/filament-simple-stats in a Laravel app?
Install it with composer require spatie/filament-simple-stats. There are no migrations, no publishable config, and no assets to publish, so installation is a single Composer command. You then use SimpleStat inside the getStats() method of an existing Filament widget class. The package requires a Filament 5.2+ admin panel to be useful.
Which Filament and Laravel versions does this package support?
Version 1.1.0 and later require Filament widgets ^5.2, and version 1.2.0 and later add Laravel 13 support. If you are still on Filament 4 you must pin to 1.0.0 and treat that branch as unmaintained. Because the package follows Filament majors closely, a Filament upgrade can turn this dependency into a Composer conflict, so pin explicitly and test upgrades.
How do I add a daily count stat card to a Filament dashboard?
Return a SimpleStat instance from your widget's getStats() method. For example, SimpleStat::make(User::class)->last30Days()->dailyCount() renders a stat card with a daily count trend over the last 30 days. The fluent chain is only a few calls, so time to a visible dashboard figure is typically measured in hours.
Can I sum a column instead of counting rows?
Yes. Chain dailySum() with a column name, for example SimpleStat::make(Purchase::class)->last30Days()->dailySum('earnings'). This aggregates the column per day across the selected period, which is useful for revenue, credits, or usage totals. The result is displayed through the standard Filament Stat widget rendering.
Can I filter the stat query with a where clause or an Eloquent builder?
You can call where() on the SimpleStat to constrain the underlying query. Since 1.2.1 you can also pass an Eloquent Builder, which means existing scoped queries for tenant, permission, or ownership filters can be reused instead of reimplemented. That builder support is the most important change for teams standardizing widgets across an application.
Does the package handle multi-tenancy automatically?
No. Scoping is not enforced centrally; each widget is responsible for the query it emits. In a multi-tenant application you should pass a pre-scoped Eloquent Builder or add the tenant where() condition on every widget. Decide as a team whether scoping lives in a shared base widget or in per-widget code before rolling this out widely.
Is it safe to use on large tables, and does it cache results?
There is no caching layer, so every stat issues at least two range aggregates: the current period and the comparison period. A dashboard with eight widgets therefore runs sixteen COUNT or SUM scans over a date range on each render. On large orders or events tables, add composite indexes covering the date column and your filters, and consider caching the aggregates yourself if you have a dashboard load budget.
How accurate is the trend percentage, and how are timezones handled?
The widget reports percentage change between the current and comparison periods, so a zero baseline, timezone drift at day boundaries, and inverted metrics such as costs or error rates can all produce a number that is technically correct but operationally misleading. Check the aggregate output against a known-good query before quoting dashboard figures. If you are migrating from hand-rolled widgets, run both side by side for a release cycle and compare.
How do I test Filament widgets built with this package?
Test them like any other Filament or Livewire widget by rendering the dashboard page or widget and asserting the stat output. Because the package only delegates to Eloquent aggregates, seeding a small dataset with known counts per day lets you assert exact values and percentages. Keep timezone-sensitive tests fixed to a single application timezone to avoid flaky day-boundary assertions.
What are the alternatives to spatie/filament-simple-stats?
The closest substitute is using flowframe/laravel-trend directly inside a custom Filament Stat widget, which gives you upstream fixes and full control over rendering. Filament's own chart widgets are a better fit if you need explorable or drill-down analytics rather than stat cards. For Nova, Backpack, or hand-rolled Blade admins this package has no role at all, so a custom implementation is the only option.
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.
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo
bernskioldmedia/laravel-harvest
bernskiold/laravel-data-scrubber
bernskiold/laravel-currency-converter
bernskiold/laravel-campaign-monitor
bernskioldmedia/laravel-autotranslate
siberfx/telegram-bot
roy-sandip/laravel-view-extended
gregsphotography/site-builder-core
roy-sandip/laravel-view
anodyne/blade-fluentui-icons
webx-ui/module-catalog-collections