ajcastro/eager-load-pivot-relations
Laravel package that eager loads relations defined on pivot models in many-to-many relationships, eliminating N+1 queries when accessing nested pivot data. Use familiar Eloquent syntax to keep role_user, post_tag, and similar pivot records fast and clean. Drop-in trait and builder methods make setup...
Architecture fit
ajcastro/eager-load-pivot-relations is a narrow, single-purpose Eloquent extension for Laravel: it lets you eager load relations hanging off BelongsToMany pivot models (e.g. with('roles.pivot.permissions')) rather than triggering N+1 queries on pivot-attached data.Integration feasibility
use statement on affected models plus updating with() calls.DB::listen / assertQueryCount), otherwise the benefit is unverifiable.Technical risk
Relation, Builder::eagerLoadRelations) change between Laravel majors, so the package is structurally exposed to Laravel upgrade cycles.Key questions
load()/loadMissing() on already-hydrated models, or only with() at query time? This drives how much call-site churn we face.Stack fit
composer.json; confirm against our pinned framework version before committing. Packages of this kind typically track the two most recent Laravel majors — verify, don't assume.Migration path
composer remove plus reverting use statements; ensure no other code depends on package-specific APIs so rollback stays cheap.Compatibility
"0.3.0", not ^0.3) and upgrade deliberately after reading the diff.staudenmeir/eloquent-eager-limit, spatie/laravel-query-builder, custom Builder macros). Two packages both hooking eagerLoadRelations is a classic silent-conflict source.Sequencing
composer.json constraints against our runtime; request a changelog from the maintainer if none exists.composer.json inline comment/ADR noting the pin rationale.Maintenance
Support
Scaling
IN (...) clauses. Validate on production-shaped cardinality, not fixtures.Failure modes
null where data previously existed. Detect via feature tests asserting pivot payload shape, not just status codes.IN clause on large datasets: slow queries / memory spikes. Detect via query-time monitoring and load tests.use statements + composer remove), which is why the opt-in, narrow-footprint integration is worth insisting on.Ramp-up
with(); the only new concept is that pivot relations are addressable. Estimate under an hour of onboarding, best delivered as a short ADR plus one exemplar call site.Recommendation pending PR #11 review: adopt, narrowly scoped and exactly pinned, contingent on confirming (a) no breaking changes in v0.3.0 and (b) declared compatibility with our Laravel/PHP versions. If PR #11 turns out to be a breaking change or the diff is unreviewable, defer and vendor the minimal implementation instead.
How can I help you explore Laravel packages today?