kirschbaum-development/eloquent-power-joins
Eloquent Power Joins brings Laravel-style joins to Eloquent. Join via relationship definitions, reuse model scopes in join contexts, query relationship existence with joins, and sort by related columns/aggregations—all with cleaner, more readable queries.
WHERE EXISTS queries with joins for relationship existence checks (powerJoinHas), potentially improving performance for large datasets or complex relationships.User → Posts → Comments → Replies).Image linked to Post/User).join() calls to relationship-based joins without breaking queries, easing database schema changes.hasOne/belongsTo with no nested joins or conditions).WHERE EXISTS logic that joins cannot replicate (e.g., recursive CTEs).join() calls needing refactoring.*"This package lets our Laravel devs write complex database queries in half the time—using the same intuitive syntax they already know. For example, instead of manually joining 3 tables with raw SQL, they’ll write User::joinRelationship('posts.comments'). It’s like Eloquent for joins, which means:
WHERE EXISTS checks with optimized joins for large datasets.
We’re talking about a 30–50% reduction in query-related bugs and maintenance overhead—worth the minimal cost of adoption."**"This package bridges the gap between Eloquent’s elegance and SQL’s power. Key wins:
posts.comments without hardcoding table names. Change the relationship? Joins stay in sync.->published()) inside join callbacks—no more duplicating WHERE logic.imageable_type for polymorphic joins (e.g., Post::joinRelationship('images')).powerJoinHas() replaces WHERE EXISTS for relationship checks, often faster for large tables.deleted_at by default; opt in/out with withTrashed().
Tradeoff: Adds ~100KB to your vendor folder. Use case: Any query with nested joins, aggregations, or complex conditions. Avoid for trivial joins or non-Eloquent projects."**"This enables cleaner, more maintainable queries for analytics. For example:
profile.city with User::orderByPowerJoins('profile.city').Post::powerJoinHas('comments', '>', 3) (join-based, not EXISTS).Image linked to Post/User) without manual type checks.
Caveat: Joins may not replicate all EXISTS semantics—test edge cases. Best for read-heavy, relationship-driven queries."*How can I help you explore Laravel packages today?