kitloong/eloquent-power-joins-with-compoships
Strengths:
topclaudy/compoships, a well-established package for composite-key relationships, ensuring compatibility with existing composite-key setups.kirschbaum-development/eloquent-power-joins, a mature package for fluent join syntax, adding compoships support without reinventing the wheel.Fit for:
tenant_id + user_id).hasOne/belongsTo fail due to composite keys (e.g., junction tables with additional constraints).Limitations:
PowerJoins, Compoships), minimizing invasive changes.eloquent-power-joins (v2+) and compoships (≥v1.0). Potential version conflicts if these packages are already in use (e.g., older compoships versions).composer require with --with-all-dependencies and resolve conflicts via composer.json overrides.| Risk Area | Severity | Mitigation |
|---|---|---|
| Composite Key Ambiguity | High | Validate all composite-key relationships in tests; document constraints clearly. |
| Performance Regression | Medium | Benchmark queries before/after integration; monitor slow queries in production. |
| Package Maintenance | Low | MIT license + active releases (2025-09-22) suggest stability, but monitor GitHub issues. |
| Breaking Changes | Low | Package is an extension, not a rewrite; risks limited to major version bumps. |
| Debugging Complexity | Medium | Composite joins may obscure query plans; use DB::enableQueryLog() for debugging. |
Composite Key Strategy:
compoships’s compositeKey() vs. manual schema definitions)?Query Complexity:
Team Adoption:
eloquent-power-joins/compoships? Will training be needed?Long-Term Viability:
eloquent-power-joins to add compoships support.)Testing:
Preparation:
compoships.composer.json to include dependencies:
"require": {
"kitloong/eloquent-power-joins-with-compoships": "^1.0",
"awobaz/compoships": "^1.0",
"kirschbaum-development/eloquent-power-joins": "^2.0"
}
composer update and resolve conflicts.Model Integration:
use PowerJoins; use Compoships; to models with composite-key relationships.hasMany(Post::class, ['team_id', 'category_id'], ['team_id', 'category_id'])).class User extends Model {
use PowerJoins, Compoships;
public function posts() {
return $this->hasMany(Post::class, ['team_id', 'category_id'], ['team_id', 'category_id']);
}
}
Query Replacement:
joinRelationship():
// Before (raw SQL)
DB::select("SELECT users.* FROM users INNER JOIN posts ON users.team_id = posts.team_id AND users.category_id = posts.category_id");
// After (Eloquent)
User::joinRelationship('posts')->get();
User::withJoinRelationship('posts')->get();
Testing:
joinRelationship().DB::enableQueryLog() and benchmarking.Deprecation:
joinRelationship() where applicable.composer.json for minimum version requirements.compoships: Ensure no conflicting composite-key definitions exist in models.eloquent-power-joins: Verify no existing PowerJoins usage that might conflict with the new package.Phase 1: Proof of Concept (1-2 weeks)
Phase 2: Pilot Integration (2-3 weeks)
joinRelationship().Phase 3: Full Rollout (3-4 weeks)
Phase 4: Optimization (Ongoing)
select() clauses to limit columns).How can I help you explore Laravel packages today?