saumini/count
A lightweight Laravel package for efficient Eloquent counting. Get accurate totals for models and relationships without loading full collections, making it useful for dashboards, list cards, and search results where performance and simple code matter.
NovaField with withCount/subquery in an afternoon." That reframing is the decision. The calculus is nearly symmetric, which should make you suspicious of accepting lifecycle risk on a component you could own outright.nova-field-count and the code is a Nova presentation field. A PM reading the marketing copy would overestimate its addressable scope. Always reconcile description, repo name, and source before committing; the gap here is small in code but large in "what problem does this actually solve."Consider it when:
app/Nova/Fields/, and own the code. Near-zero downstream usage and a single maintainer make a direct dependency a poor default.Look elsewhere when:
withCount, a Blade component, Filament, or your BI layer.Executives. This is a small, free (MIT), single-purpose add-on for the Nova admin panel we already pay for. It puts counts — "this account has 12 open tickets" — directly on the record screen, where operators currently click through relations or file data requests with analytics. It is a convenience, not a platform bet: roughly 28 GitHub stars, no downstream dependents, one maintainer. Treat it as a snippet we adopt and own rather than a vendor relationship — pin and copy it into our codebase. Cost is hours, not a budget line; the return is fewer ad-hoc data requests to ops and analytics. If it breaks or is abandoned, we replace it with our own field in under a day — the downside is bounded and the decision is fully reversible. One caveat to carry forward: the public description oversells it as a general counting library, while the code is Nova-specific and display-only.
Engineering. The ask is to wrap a withCount-style subquery in a Nova field so counts render on index and detail without loading relations or maintaining per-resource accessors — the N+1 fix, packaged. We'd vendor it (pin and copy into app/Nova/Fields/) rather than depend on it directly, given the thin maintenance signal and tiny code surface. Scope is explicitly one integer per record; it has no write path, migrations, config, queues, or auth implications, so it can be trialled on a single Resource with no blast radius and rolled back with one deleted line.
Before rollout, two gates, both cheap:
resolve/resolveUsing implementation to confirm the field reads a {relation}_count attribute loaded via withCount on indexQuery, rather than issuing a query per row. Confirm which Nova majors are supported (^4.0 only, or ^5.0 too), and verify the exact Packagist name and publisher against the repo, given the repo/package naming mismatch (nsaumini/nova-field-count vs. saumini/count) — that mismatch is exactly the shape of a dependency-confusion or typo-squat mistake. Check whether assets are pre-built and committed, so no JS build chain is introduced.composer.json, and add this package to the Nova upgrade checklist: if the field breaks on a Nova bump, it breaks silently in the browser, not in CI.If either gate fails, the fallback is a 20–40 line in-house NovaField, or Text::make()->displayUsing() over a withCount attribute. And if we discover we need more than counts — sums, trends, drill-down, cross-record comparison — that's a signal to escalate to a real metrics workstream rather than extend this field in place. Flag it and we'll re-scope rather than accrete.
How can I help you explore Laravel packages today?