Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Query Enrich Laravel Package

sbamtr/laravel-query-enrich

A Laravel package that adds expressive query enrichment helpers, letting you append computed values, relationships, and metadata to Eloquent results cleanly while reducing boilerplate and keeping data shaping close to your queries.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit

  • The package is a developer-ergonomics layer over Eloquent's Builder (and/or Model), not an infrastructure component. It does not add a service, a queue, a schema change, or a runtime dependency beyond Composer. Blast radius is therefore small and reversible.
  • 1.4.0 materially widens the picture from the prior assessment: the release notes reference DBFunction, case->when, and passing subqueries as arguments. This is not a thin selectRaw wrapper — it is a small SQL-expression DSL (functions, conditional CASE expressions, subquery composition) that renders into the query builder. That is still a convenience layer, but it is a larger convenience layer with more of its own semantics to learn and to break.
  • It fits cleanly only where Eloquent or the query builder is already the data-access layer. Applications using repositories returning DTOs, or hand-rolled PDO/Doctrine layers, get nothing from it.
  • Because it registers builder macros or a trait, it composes with existing scopes and packages, but shares a global namespace with them. Macro name collisions remain a real, low-probability hazard — and the growing API surface (DBFunction, case, when) increases collision candidates slightly.
  • New in 1.4.0: Enum support as a value type. This is a genuine ergonomics win for teams already modelling status columns as backed enums, and it implies the package performs its own value coercion before binding — a code path that must be included in the security review.

Integration feasibility

  • Still trivial to adopt mechanically: one composer require, MIT license, no dependents to inherit. The absence of dependents (0) remains a double-edged signal, though 1.4.0 shows external contributors exercising the code, which is mild positive evidence of real-world use.
  • This release resolves the binding constraint identified previously. "Laravel 13.x Compatibility" declares support for a Laravel major that most of the ecosystem has not yet caught up to. Re-verify our current Laravel minor against the illuminate/* and PHP require constraints — the package may now support a wider range than our pinned version, which is fine, or may have dropped an older major, which is not.
  • Contributor mix improved: three external contributors across four functional PRs, including an automated compatibility PR from laravel-shift. Treat the latter as a signal that the maintainer has wired up ecosystem-standard tooling, not as independent human review.
  • Still "evaluate, don't standardize" territory on stars and maintainer count, but the maintenance signal is now measurably better than at the last assessment.

Technical risk

  • Injection surface. Unchanged as the highest-severity finding, but the audit scope has grown: DBFunction arguments, case->when conditions, Enum coercion, and — critically — subquery arguments (fixed in PR #13). Subquery handling in query builders is historically where parameter binding gets lost in favour of string concatenation. Read that diff specifically, not just the README.
  • Dialect divergence is now a demonstrated risk, not a theoretical one. PR #14 fixes an SQLite exists condition. Good that it was found and fixed; notable that it shipped broken. Any expression this package renders must be validated on both our production engine and our test engine, because the package evidently does not guarantee parity across all three of MySQL/Postgres/SQLite.
  • Silent breakage. Builder internals and pagination query rewriting (getCountForPagination re-derives selects) change across Laravel majors. A package that now composes subqueries and functions into SELECT has more surface exposed to that rewriting than a pure selectRaw helper.
  • Semantic drift on a minor bump. PR #9 (isNull as a case->when parameter) and PR #13 (subquery arguments) change how arguments are interpreted. Nothing here reads as breaking, but a 1.3.x call site could behave differently under 1.4.0. Pin exactly, and diff behavior rather than assuming patch-level safety.
  • Maintainer concentration. Still one person, no stated security policy or release cadence guarantee. Meaningfully mitigated by the Laravel 13 support landing promptly and by outside contributions.

Key questions

  1. Does it use bound parameters exclusively for all interpolated values — specifically in the DBFunction and subquery argument paths touched by PR #13? Show me the code path.
  2. Which Laravel and PHP versions are declared supported in 1.4.0, and did the Laravel 13 support work narrow the supported range for older majors?
  3. Is there a CI matrix covering our production database engine, or only SQLite? The exists fix in PR #14 suggests SQLite is the primary test target.
  4. Do the case->when and Enum changes in 1.4.0 alter behavior for existing 1.3.x call sites, or are they strictly additive?
  5. Does it behave correctly with paginate(), withCount(), and toBase() — now including cases where a subquery is passed to DBFunction?
  6. What is the removal cost if abandoned — trait removal, or pervasive call-site edits?

Integration Approach

Stack fit

  • Laravel monolith or Laravel API service on Eloquent: good fit, low friction. Stronger fit than previously assessed if we use backed enums for status/type columns, given the new Enum support.
  • The case->when API is the most interesting addition for us: conditional aggregation and derived buckets are exactly the queries teams otherwise write as raw strings. Route those through the package or keep them native — but pick one convention, don't mix.
  • Anything crossing into reporting/analytics heavy SQL: better served by views, generated columns, or a dedicated read model. The broader DSL in 1.4.0 makes it easier to accidentally build a reporting layer here. Don't.

Migration path

  • There is no migration in the data sense — this is additive. The real work is containment: wrap all usage in one internal abstraction (a custom builder macro, a QueryEnricher service, or a small EnrichesQueries trait we own) so upstream calls appear in exactly one file. That file is the entire removal cost. This matters more now that the API surface is wider — more surface means more places for call sites to sprinkle.
  • Do not let the package's API leak into controllers, resources, or domain logic. If the package is the only thing that knows it exists, swapping it for native selectRaw/CASE later is a one-day task.

Compatibility

  • Pin the exact version (1.4.0, no caret range) for the pilot, as before. Given the behavioral changes in PRs #9 and #13, do not float across 1.3.x → 1.4.0 without re-running characterization tests.
  • Confirm the Laravel 13 support did not drop our current major, and re-read the require block rather than trusting the changelog headline.
  • Confirm database driver parity: run the pilot suite against both the production engine and the CI test engine. This is now a required gate, not a nice-to-have, given the SQLite exists defect.

Sequencing

  1. Source read and injection audit, explicitly covering DBFunction, case->when, Enum coercion, and subquery arguments (1 day, up from 0.5 — the surface grew).
  2. Branch spike against 1.4.0: apply to two or three real, read-heavy queries, including at least one case->when and one subquery-argument case; assert identical results versus the current native implementation (0.5–1 day).
  3. Wrap in the internal abstraction and add characterization tests around pagination counts and aggregate totals (1 day).
  4. Ship to one non-critical endpoint; observe for one release cycle.
  5. Decide: promote to a second surface, or remove and keep the native equivalent. Decide explicitly — do not let a pilot drift into permanence.

Operational Impact

Maintenance

  • Ongoing cost is not the package's runtime behavior; it is tracking upstream against our Laravel upgrade cadence. Budget roughly one to two days per quarter, concentrated around Laravel majors, and assign a named owner.
  • 1.4.0 is evidence the maintainer is tracking Laravel majors proactively — Laravel 13 support landed while much of the ecosystem lags. That is a genuinely encouraging signal and slightly lowers the abandonment probability relative to the prior assessment. It does not eliminate it.
  • Mitigation remains cheap and should be pre-agreed: fork to an internal namespace or replace the calls with native SQL. Both viable only if the containment wrapper exists.
  • MIT license means we can vendor or fork without legal friction.

Support

  • Community-only. No SLA, no vendor, no security advisory feed. Expect GitHub-issue latency measured in weeks.
  • Counterpoint from this release: four PRs merged, two first-time contributors, prompt turnaround. Practical responsiveness is better than the formal posture suggests.
  • Requirement unchanged: an internal champion who can read the source and patch it. If no one on the team can own a ~200–400 line PHP helper, do not adopt.

Scaling

  • Runtime overhead remains negligible — it constructs SQL, it does not execute or cache anything.
  • The scaling risk is query-plan risk. Raw expressions can defeat indexes, and computed columns in SELECT interact badly with covering indexes. Subquery arguments to DBFunction are especially prone to per-row execution if they land in a WHERE or SELECT on a high-volume table. Any enriched query touching a large table needs an EXPLAIN review, same as hand-written SQL — and now more so than before.

Failure modes

  • Laravel major upgrade → macro or builder-internals break → wrong results rather than exceptions. Characterization tests around pagination counts and aggregate totals are mandatory.
  • User input reaching an interpolated expression → injection. Treat as a security-review gate, not a code-review nit.
  • Dialect divergence between production and test databases → tests pass, production errors. This has already happened once upstream (SQLite exists, PR #14). Assume it can happen again.
  • Silent semantic change on a minor bump → a 1.3.x-shaped call behaves differently under 1.4.0. Pin exactly.
  • Abandonment → unpatched compatibility break with no upstream fix. Contained by the wrapper.

Ramp-up

  • Hours for any developer already fluent in Eloquent, but budget slightly more than before: DBFunction, case->when, Enum coercion, and subquery arguments are four distinct concepts with their own rules.
  • Publish a short internal note: when to use the helper, when to use native selectRaw, and where the wrapper lives. The wider 1.4.0 API makes this note more necessary, not less — without it the package will be sprinkled ad hoc and the containment strategy quietly evaporates.

Recommendation Adopt conditionally — unchanged in direction, modestly improved in confidence. Pilot 1.4.0 specifically (not a 1.3.x floor) on a bounded set of read queries behind an internal wrapper, gated on an injection audit that explicitly covers the subquery and DBFunction argument paths, and on a two-engine verification of rendered expressions. Do not standardize, and do not adopt at all if the audit finds string interpolation of non-constant values.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log