eliseekn/laravel-metrics
Generate metrics and trends from your Laravel models for dashboards. Group counts and sums by day, month, or year, set custom date/label columns and tables, use date ranges, and query via Eloquent or the query builder. Supports MySQL, PostgreSQL, and SQLite.
count, sum, average, max, min) × period (byDay/Week/Month/Year, between, from) × output (trends, metrics, metricsWithVariations in absolute or percent). When a stakeholder asks "can we show change vs. last month?", the answer is a parameter, not a ticket.fillMissingData with label auto-discovery forces an explicit product decision we usually forget: what does a zero-activity day look like on the chart — a gap, a zero, or carried-forward? Having it as a named toggle means it gets decided in the PRD rather than discovered in a bug report.labelColumn plus groupData(['pending','delivered','cancelled']) supports the "stacked bar by status" requirement without a second round of engineering. This is the difference between a dashboard that ships and one that ships and immediately gets a v2 request.LaravelMetrics::query(Model::query()->where('team_id', ...)) means per-customer dashboards are scope composition, not new infrastructure — a lever for packaging a "reporting" tier.config('app.locale') removes a small but recurring class of "our German customers see English months" defects, which matters if you sell into non-English markets.Adopt when most of these hold:
Look elsewhere when any of these hold:
labelColumn escape hatches cover simple cases only; past that you are writing raw SQL anyway.2.x/3.x/4.x branches tied to Laravel versions. That is workable, but it means your composer constraint and your Laravel upgrade are coupled — verify the target branch actually has the features you scoped.To executives (30 seconds): We need a first dashboard for [customers/ops] and the honest build estimate is 3–4 weeks of engineering. This MIT-licensed Laravel package covers roughly 80% of that — aggregation, time-bucketing, gap-filling, and "vs. previous period" deltas — across MySQL, Postgres, and SQLite. Recommendation: a two-day spike now, and if it holds, we ship the dashboard this cycle and defer the BI tool purchase. Cost is $0 in licensing; the real cost is the half-day we spend wrapping it behind our own interface so we're not locked in.
To engineering (the ask): Prototype the three metrics on our actual schema for one day, then answer two questions: (1) does the generated SQL use our indexes, and (2) is the HasMetrics / LaravelMetrics::query() API clean enough to sit behind a MetricsService we own? If yes, we adopt with a mandatory adapter boundary and a pinned branch matching our Laravel version — no direct package calls from controllers. If the spike shows table scans or fights our query scopes, we stop and build the ~200 lines ourselves.
Risk statement to state out loud: Low adoption, single maintainer, and branch-per-Laravel-version means we should assume we may fork. The adapter boundary and a pinned, tested version are non-negotiable conditions of adoption — not because we expect failure, but because a dashboard silently breaking after a dependency bump is a customer-visible incident.
How can I help you explore Laravel packages today?