jhumanj/laravel-model-stats
Laravel Model Stats lets you track and query statistics for your Eloquent models over time, making it easy to add counts, trends, and date-based metrics to dashboards and reports with minimal setup.
Architecture fit. The package is an additive, read-only presentation layer: a service provider, a config file, a set of dashboard routes, and (typically) publishable front-end assets, with stat definitions written as closures or small classes that run aggregate queries against Eloquent models. It does not own a data store, so it introduces no schema coupling and no dual-write problem. That makes it a clean fit for a Laravel monolith or modular monolith where an internal admin/operator console already exists, and a poor fit for an API-only product with a separate SPA admin, or for teams that already run a BI tool (Metabase, Redash, Looker) — you would be creating a fourth place operators look for numbers instead of the second.
Integration feasibility. Cheap to evaluate. A composer install, config publish, two or three stat definitions, and a route gate gets you a credible demo in a day. The effort is not in the install; it is in (a) defining metrics the business actually agrees on, (b) making the underlying aggregate queries fast on production-sized tables, and (c) proving the route is authorized. Treat the spike as a query-cost and security experiment, not a UI experiment.
Technical risk.
COUNT/SUM grouped by day) on your largest tables. Naive whereDate/groupBy implementations produce sequential scans; an admin refreshing a dashboard can generate more database load than a feature release.withoutGlobalScopes, cross-connection queries) is a cross-tenant leak vector.Key questions.
Stack fit. Laravel 9/10-era, PHP 8.1+, Blade/Vue front end, composer-only install. It fits an internal staff or SaaS operator console — a back-office analytics tab — not a customer-facing surface.
Migration path. Purely additive; no data migration is expected (verify via published migrations). Install behind a feature flag and a namespaced route prefix (/admin/stats), ship to staging, and shadow-compare every metric against the existing SQL report or spreadsheet for one sprint before anyone makes a decision from it. Exit path is trivial: delete the package, keep the queries you liked as scheduled jobs writing to a rollup table.
Compatibility. Pin the package, then run composer why-not against your target framework to see how far behind it is. If you are on Laravel 11+, budget a fork with a widened illuminate/* constraint and a CI job that runs your app's test suite against it on every upgrade.
Sequencing.
tenant_id, created_at), set cache TTLs per stat, and log any stat exceeding a latency budget.Maintenance. Small code footprint, but a stale dependency you will likely end up forking. Budget roughly one engineer-day per quarter for framework-compatibility upkeep, plus the annual Laravel upgrade cycle. No vendor; GitHub issues only. Assign a named internal owner before merge.
Support. MIT, no SLA, 242 stars means a thin community — expect to debug it yourself. The mitigation is that it is read-only and removable, so support burden is bounded and never blocks revenue paths.
Scaling. The dashboard scales with your table sizes, not with the package. Synchronous aggregates are fine to roughly low millions of rows with proper indexes and a 5–15 minute cache; beyond that, pre-aggregate into a daily rollup table via the scheduler and have the dashboard read the rollup. Point it at a read replica. Cap concurrent refreshes — a dozen admins hitting refresh during a board meeting is a real, if embarrassing, load spike.
Failure modes.
Note the favorable asymmetry: every failure mode is read-only. There is no data-corruption or dual-write risk, which is why a low-cost trial is justified even given the maintenance concerns.
Ramp-up. A Laravel-fluent engineer is productive in half a day; the front end is not the learning curve. The real ramp is domain semantics — what counts as an "active user," which timezone the day buckets use, whether refunded orders count — and that knowledge lives with the business owner, not the package. Operations needs a two-line runbook: how to disable the dashboard via flag/config, and how to clear the stat cache.
How can I help you explore Laravel packages today?