paulhenri-l/eloquent-builder-decorator
A Laravel package for decorating Eloquent query builders. Wrap builders to add reusable query logic, filters, and composable behavior without touching your models. Keeps query customization clean and testable.
UserQuery::active()->recent()) without leaking Illuminate\Database\Eloquent\Builder calls into controllers, jobs, and console commands. That's a real design-quality lever when you're preparing for a modularization or package-extraction effort.Consider the pattern when:
Look elsewhere — or implement in-house — when:
Builder gained strict return types and contract changes; a package last touched in April 2020 is unlikely to survive. Verify compatibility before it enters a design doc, let alone a composer.json.app/Support/ costs hours, not weeks, and removes the supply-chain and upgrade risk entirely.*Query classes that contain rather than decorate a builder, or Illuminate\Database\Eloquent\Builder::macro cover most of the same ground with zero new dependencies.__call to an underlying builder is easy to misuse; expect onboarding cost and confusing stack traces if the team is junior.PM recommendation: treat this repository as a reference implementation and design precedent, not a dependency. Cite it in the design doc, budget a small spike to port the pattern internally, and avoid adding a stale third-party package to your upgrade path.
To executives: This is a small, single-purpose code-organization library for our Laravel backend. It doesn't ship user-facing features; it makes query logic easier to reuse and test, which reduces the cost of future features that filter data (permissions, tenancy, reporting). Given its age and negligible adoption, I do not recommend adding it as a dependency — instead we'd copy the ~100-line pattern internally at near-zero cost and keep full control. Net ask: a short engineering spike, no vendor commitment, no licensing or procurement work.
To engineering: It demonstrates a clean way to layer composable query logic over Illuminate\Database\Eloquent\Builder via the decorator pattern — better separation than a model bloated with scopes, and independently testable. Caveat: last release April 2020, zero dependents, 11 stars, and Laravel's builder contract has changed since. Proposal: use it as the design reference, implement the decorator ourselves against our pinned Laravel version, and add a thin test suite so the pattern survives framework upgrades. Revisit only if the upstream repo is revived and version-pinned to our stack.
How can I help you explore Laravel packages today?