- What Laravel and Filament versions does spatie/filament-simple-stats support?
- This package requires Laravel 10+ and Filament v2 or v3. It leverages Filament’s widget system, so ensure your Filament installation is up-to-date. Check the [Filament changelog](https://github.com/filamentphp/filament) for breaking changes that might affect widget compatibility.
- How do I add a stat widget to my Filament dashboard?
- Register widgets in your `app/Providers/Filament/AdminPanelProvider.php` using the `widgets()` method. For example, add `Total::make()` or `Trend::make()` to display prebuilt stats. Configure queries or models directly in the widget class or via the `getStats()` method.
- Can I customize the appearance or data source of the widgets?
- Yes, widgets are highly customizable via Filament’s widget API. Override methods like `query()`, `format()`, or `description()` in your widget class. For visual tweaks, use Filament’s built-in styling options or extend the Blade templates in the package’s `resources/views` directory.
- Does this package work with PostgreSQL or only MySQL?
- It works with any Laravel-supported database, including PostgreSQL and SQLite. The package relies on Eloquent queries, so ensure your models and database indexes are optimized for performance, especially for trend-based queries.
- How does caching work for stat widgets in production?
- Widgets inherit Filament’s caching layer. Configure caching via Filament’s `widgets()` method or use `cacheFor()` in your widget class. For high-traffic dashboards, set a reasonable TTL (e.g., 5 minutes) and monitor query load to avoid stale data.
- What if I need a custom visualization, like a gauge chart, that isn’t included?
- The package is opinionated but extensible. Fork the widget class and override the `view()` method to use a custom Blade template or integrate a frontend library like Chart.js. Alternatively, build a new widget from scratch using Filament’s widget API.
- Are there performance concerns with large datasets (e.g., millions of rows)?
- Trend queries can become expensive with high-frequency data. Optimize by indexing `created_at` or timestamp columns and use `laravel-trend`’s `cache()` method. For per-minute metrics, consider aggregating data in a separate table or using database views.
- How do I restrict dashboard access to specific user roles?
- Use Filament’s built-in authorization. Define policies in `app/Policies` or leverage Filament’s `canAccessDashboard()` method in your `AdminPanelProvider`. The package doesn’t add extra auth layers—it relies on Filament’s existing RBAC system.
- What’s the migration path if I switch from Filament to another admin panel?
- The package is tightly coupled with Filament, so migrating to another panel (e.g., Nova) would require rewriting widgets. However, the underlying `laravel-trend` logic remains reusable. Extract stat queries into separate services for easier portability.
- How do I test widget functionality in CI/CD?
- Test widget queries and caching by mocking Eloquent models and Filament’s cache layer. Use Laravel’s `refreshDatabase()` or `migrate:fresh` in tests. Verify widget rendering with `filament:test` commands or browser tests targeting `/admin/dashboard`.