nilportugues/eloquent-repository
A Laravel package that adds a repository layer for Eloquent models, with reusable query criteria, caching support, and cleaner separation between persistence and application logic.
count and exists to ReadRepository matters more than a typical patch note. Until now, the read contract presumably could not answer "how many" or "does any row match" without pulling the full write-side surface or dropping back to raw Eloquent. Those two methods are the load-bearing primitives for pagination counts, dashboard tiles, empty-state rendering, and cheap existence checks. This signals the library now covers the common read paths, not just find/all.count without hydrating models; "has any unread notifications / pending invites / open tickets" checks that should be a single exists query rather than a collection load; feature gating and onboarding logic keyed on record existence. exists returning a boolean is also a cheaper, more explicit contract than count() > 0.count supports. Treat it as a "upgrade on your normal cadence" item, not a hotfix.Consider adopting when:
ReadRepository/write contracts rather than concrete Eloquent models. The new count/exists methods make that boundary meaningfully usable for read-heavy flows.interface FooRepository / class EloquentFooRepository pair repeatedly and would rather inherit a maintained one.Look elsewhere (or stay on raw Eloquent) when:
Model::query() call site.with() eager-load graphs, chunkById, cursor pagination, scopes, upsert, raw expressions. Repository layers tend to leak or force escape hatches for these, and a leaky abstraction is worse than none.count and exists arriving only in 2.2.2 suggests the read API has been growing incrementally; audit the write side and any query-object/builder surface for similar gaps before standardizing.For executives (30 seconds): We're evaluating a small open-source Laravel package that standardizes how our application talks to the database. The new 2.2.2 release is a low-risk patch — no breaking changes — and it fills in two routine read operations (count and exists) that the library previously lacked, plus a defensive bug fix. Net effect: the abstraction is now complete enough for our common read use cases, and the maintenance signal is positive. No cost, no contract, reversible. Recommendation: trial it on one bounded module, not a codebase-wide mandate.
For engineering leads: 2.2.2 adds count and exists to ReadRepository. That closes the most annoying gap in the read contract — we can now do paginated totals and existence checks against the interface instead of reaching through to Eloquent, which was the main reason our mocks kept leaking. The divide-by-zero fix is defensive and likely touches pagination/aggregate arithmetic; upgrade on normal cadence, no urgency, no migration work. Before we standardize: audit the write-side contract for the same kind of gaps we just saw closed on the read side, confirm the package's Laravel version support against our matrix, and check maintainer responsiveness. Then pilot on one module with a real swap case (e.g. a cached or read-replica implementation) so we can prove the seam pays for itself.
Caveat to carry into the decision: this assessment is based solely on the 2.2.2 release notes, not on source review, benchmarks, or maintenance history. Treat the maturity read as provisional until someone spends an hour in the repository.
How can I help you explore Laravel packages today?