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 Hasmanywithinverse Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Performance/API latency investments: This package eliminates a common source of redundant queries when child models need a reference back to their parent (e.g., serializing a comment with its post, an order item with its order). It lets you load a hasMany and have the inverse relation pre-populated, reducing N+1 query risk without custom code.
  • Roadmap and platform upgrades: v1.4.2 adds Laravel 10 support and drops Laravel 8. This directly informs upgrade planning: teams still on Laravel 8 must either pin to v1.4.1 or prioritize the framework upgrade; teams moving to Laravel 10 can adopt this release safely.
  • Build vs. buy: The underlying behavior is small enough to implement in-house, but the package encapsulates edge cases and is maintained by a known Laravel ecosystem vendor (Archtech). Buying/adopting is reasonable when engineering time is scarce or when you want a supported, tested utility rather than bespoke relationship code.
  • Use cases to prioritize: API resource transformations, nested resource serialization, audit/activity feeds, and any parent-child model pair where the child response includes parent context. Evaluate it wherever you see repeated with('parent') calls or manual setRelation() workarounds.

When to Consider This Package

  • You are on Laravel 9 or 10 and have hasMany relationships where child records frequently need their parent relation available without an extra query.
  • You want a drop-in, low-ceremony relationship that behaves like native Eloquent and avoids custom query logic in controllers or resources.
  • You are planning or executing a Laravel 10 upgrade and want dependencies that already support it.
  • You value maintainer responsiveness and ecosystem fit over building a one-off internal helper.

Look elsewhere or defer adoption if:

  • You are still on Laravel 8 — v1.4.2 explicitly removes support, so you would need to remain on v1.4.1 or upgrade Laravel first. This is a breaking platform constraint, not a runtime breaking change for supported versions.
  • Your relationship needs are better served by native eager loading, setRelation(), or API resource patterns and you do not want another dependency.
  • You require long-term vendor SLAs or the package's maintenance cadence does not meet your risk tolerance.
  • You need advanced relationship features beyond inverse hydration (e.g., custom pivots, polymorphic complexities) that the package does not target.

How to Pitch It (Stakeholders)

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.

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.
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin