korridor/laravel-has-many-merged
Laravel package adding a “hasManyMerged” relationship to combine results from multiple hasMany relations into one merged collection/query. Useful for aggregating related models across different types or sources while keeping a familiar Eloquent API.
Feature Development:
orders, returns, and payments into a single transactions relationship for financial dashboards).comments, replies, and messages into a conversations feed)./posts/{id}/comments endpoint that merges comments, replies, and likes).Roadmap Priorities:
Model::whereIn()->orWhereIn()) with a reusable, tested solution.Use Cases:
products, variants, and inventory into a single product_details relationship for real-time catalogs.user_activity, notifications, and collaborations into a unified timeline for customer portals.events, metrics, and logs from multiple tables into a single performance_summary for reporting.hasMany relationships from legacy systems into a normalized API layer.Adopt When:
Model::with(['relation1', 'relation2'])->get() followed by manual array merging).comments and replies based on user permissions).ids or prioritizing created_at).Look Elsewhere If:
hasMany through hasMany through hasMany); consider raw SQL, a graph database, or a dedicated analytics tool.price from products and discounts into a single effective_price); a custom accessor or macro may be simpler.For Executives: "This package eliminates a common bottleneck in Laravel apps: manually merging multiple ‘has many’ relationships into a single, clean dataset. For example, instead of writing custom SQL or post-processing code to combine a user’s orders, reviews, and support tickets—each stored in separate tables—we can fetch them in one query with built-in deduplication and sorting. This cuts development time for features like unified customer profiles, real-time dashboards, or multi-source analytics by up to 70%, while keeping our codebase maintainable. It’s a force multiplier for teams building data-rich applications."
For Engineering:
*"Problem: We’re wasting time writing and debugging custom logic to merge hasMany relationships (e.g., Model::with(['orders', 'returns'])->get() followed by manual array merging). This leads to:
Solution: korridor/laravel-has-many-merged adds a hasManyMerged relationship that:
hasMany relations in a single query.with(), JsonResource, eager loading).Impact:
/users/{id}/activity] and measure the reduction in query complexity and dev time."*For Product/Design: *"This package helps us deliver richer, data-driven features without overloading the backend. For example:
users + sessions + purchases)./products/{id} includes variants, reviews, and inventory in one call).
We’ll avoid ‘data silos’ in the UI by merging the data efficiently and consistently—faster loads and a smoother experience for users."*How can I help you explore Laravel packages today?