msafadi/laravel-eloquent-join-with
HasOne/BelongsTo relationships. Justify infrastructure investments (e.g., scaling DBs) by improving query efficiency.User + Profile, Address) in a single query.Product + Inventory/Reviews without chained queries.Order + Customer demographics).join() + select() logic with a maintainable, standardized approach.HasOne/BelongsTo relationships with high query volume (e.g., >100k/month).with() nesting or manual join() optimizations.HasOne/BelongsTo only).leftJoin, where conditions on joined tables) beyond what joinWith() offers (may require raw SQL or query scopes).*"This package cuts database query time by 50–80% for relational data by replacing multiple queries with a single optimized join. For example, loading a user’s profile + address—currently 3 queries—becomes one. This directly improves:
*"Problem: Eloquent’s with() loads relationships sequentially, causing N+1 queries. Solution: joinWith trait replaces with() for HasOne/BelongsTo with a single optimized query, using existing relationships.
// Before (2 queries):
User::with('profile')->find(1);
// After (1 query):
User::joinWith('profile')->get();
Order::joinWith('customer', 'shippingAddress'))."*How can I help you explore Laravel packages today?