- Is lacodix/laravel-metric-cards ready for production use?
- No, this package is explicitly marked as **work-in-progress (WIP)** and not ready for production. The README states APIs and features may change, so use it only for testing or non-critical projects. Avoid deploying to live environments.
- What Laravel versions does this package support?
- The package targets **Laravel 8+ and 9+**, requiring PHP 8.0+. Check the `composer.json` constraints for exact version requirements. Legacy Laravel (pre-8.0) is unsupported due to modern PHP dependencies.
- How do I define a basic metric card in this package?
- Use the `Metric::create()` method with a name, query, and optional styling. Example: `Metric::create(['name' => 'active_users', 'query' => fn() => User::where('active', true)->count()])`. The package handles rendering via Blade or frontend frameworks like Inertia.js.
- Can I use this package with Livewire or Inertia.js?
- Yes, the package is designed for **dynamic dashboards** and works seamlessly with Livewire (for server-side reactivity) or Inertia.js (for SPA-like behavior). Ensure your frontend framework supports dynamic visibility toggles for features like invisible metrics.
- What are 'invisible values' and how do I enable them?
- Invisible values allow metrics to be conditionally hidden (e.g., until thresholds are met). Enable them by adding `'visible' => false` to your metric definition. The frontend must support dynamic visibility (e.g., Vue’s `v-show` or CSS classes).
- How do container queries work, and when should I use them?
- Container queries group metrics by a field (e.g., `user_segment`) for granular dashboards. Use them for **multi-dimensional analytics**, like comparing metrics across user segments. Example: `Metric::containerQuery(['group_by' => 'segment', 'metrics' => [...]])`.
- Will this package cause N+1 query issues with container queries?
- Yes, container queries can introduce N+1 risks if not optimized. Mitigate this by **eager loading relationships** (e.g., `with('segment')`) or using Laravel’s query caching. Test with large datasets (10K+ records) to validate performance.
- Are there alternatives to this package for Laravel metric cards?
- For production-ready alternatives, consider **Laravel Nova’s built-in metrics**, **FilamentPHP’s widgets**, or **custom Blade components** with libraries like Chart.js. If you need WIP flexibility, this package is experimental but may evolve into a solid solution.
- How do I test if this package works with my existing Laravel app?
- Start by adding it to `composer.json` and publishing the config if needed. Test with a single metric using `php artisan metric-cards:test` (if available) or manually verify Blade/Inertia rendering. Monitor queries with Laravel Debugbar for performance issues.
- What should I do if I encounter breaking changes in future updates?
- Pin the package version in `composer.json` (e.g., `^0.10.0`) to avoid auto-updates. Monitor the GitHub repo for changelogs and test updates in a staging environment. If major changes occur, refactor your metric definitions incrementally.