biiiiiigmonster/hasin
biiiiiigmonster/hasin brings recursive "has in" relationship queries to Laravel's Eloquent ORM, letting you fetch ancestors, descendants, and other nested tree data with fluent, hasMany-style syntax instead of raw recursive SQL. Ideal for category trees, comment threads, and org charts.
hasin swaps Eloquent's correlated EXISTS subqueries (from has() / whereHas()) for whereIn-style queries against the related table's keys. This is a targeted lever for endpoints where whereHas shows up in slow-query logs — typically paginated index screens, admin dashboards, search/filter UIs, and CSV/report exports.laravel-shift. That pattern is "quiet and maintained," not "actively developed." Record it as such so it isn't re-litigated every upgrade cycle.?filter[relation]= parameters, "customers with at least one overdue invoice" style segment builders, and any listing where the relationship table is large relative to the parent table.Adopt when most of the following hold:
EXPLAIN or APM shows correlated subqueries on a relationship filter dominating a hot path, and the related table has enough rows that the planner's row-by-row evaluation hurts.whereIn on an indexed foreign key consistently beats EXISTS.Look elsewhere or defer when:
has() / whereHas() is correct, zero-dependency, and fast enough. Adding a package here buys nothing.staudenmeir/eloquent-has-many-deep instead of stretching this one.withCount-style aggregates, not existence filtering.For executives (one paragraph): We are evaluating a small, free, open-source Laravel package that makes one common type of database query substantially cheaper. It targets list-and-filter screens that slow down as data grows — the ones users complain about and that drive database load. There is no license cost, no vendor relationship, and it is a handful of lines to adopt. The v5.1.0 release is a compatibility update for the next Laravel version, with no breaking changes, which means it stays viable through our planned framework upgrade rather than becoming upgrade debt. Risk is low and reversible.
For engineering (the actual argument): Thin API surface, drop-in, and it removes correlated subqueries from our hottest filter paths. Two caveats to own up front: it is effectively single-maintainer, and release velocity is low — this version is Dependabot bumps plus a Laravel 13 compatibility fix. That is a maintenance signal, not a red flag, but it means we should not depend on upstream for roadmap. Mitigations: wrap it behind our own Eloquent scope so the call sites are ours, pin the version, and add a benchmark plus query-count assertion to CI so a future swap is a one-file change. Also verify our specific whereHas closures translate correctly — especially anything referencing the parent table.
The ask: Approve a one-sprint spike — adopt in a single read-heavy service, benchmark before/after against one real endpoint, and report. Roll forward or revert on the numbers.
How can I help you explore Laravel packages today?