stancl/laravel-hasmanywithinverse
Laravel's hasMany leaves the inverse relation unset, so accessing the parent from each child triggers extra queries. This package adds hasManyWithinverse, which hydrates the inverse automatically—so $child->parent is already loaded without N+1.
hasMany and have the inverse relation pre-populated, reducing N+1 query risk without custom code.with('parent') calls or manual setRelation() workarounds.hasMany relationships where child records frequently need their parent relation available without an extra query.Look elsewhere or defer adoption if:
setRelation(), or API resource patterns and you do not want another dependency.For executives: This is a small, focused Laravel utility that reduces database load and improves API response times by preventing redundant queries in common parent-child data flows. The new release adds Laravel 10 support, which aligns with our platform upgrade path, and drops Laravel 8, which only affects teams still on the older framework. Adoption is low-risk and low-cost, with a clear fallback (pin to the prior version) if needed.
For engineering: v1.4.2 is a compatibility release: Laravel 10 is now supported and Laravel 8 is no longer supported. There are no new runtime features or deprecations in the package API itself. If we are on Laravel 9/10, this is a safe upgrade and a useful tool for eliminating inverse-relation N+1 queries. If any service remains on Laravel 8, we should either keep that service on v1.4.1 or sequence the framework upgrade before adopting this release. Treat the Laravel 8 removal as a platform constraint to track in the upgrade backlog, not as a code-level breaking change for supported environments.
How can I help you explore Laravel packages today?