awobaz/compoships
Adds composite-key relationship support to Laravel Eloquent. Define hasOne/hasMany/belongsTo relations matching two or more columns so eager loading works with legacy or third‑party schemas, using a custom base Model or Compoships trait.
Strengths:
attach(), sync()), critical for scalable applications.belongsToMany to composite keys, a gap in core functionality.Limitations:
Awobaz\Compoships\Database\Eloquent\Model or use the Compoships trait, which could conflict with existing inheritance hierarchies or third-party traits.where clauses (e.g., hasMany(Task::class)->where('team_id', $this->team_id)) must be refactored to use Compoships syntax.belongsToMany, custom pivot models must extend Awobaz\Compoships\Database\Eloquent\Relations\Pivot, requiring updates to existing pivot classes.Awobaz\Compoships\Database\Eloquent\Factories\ComposhipsFactory for relationship testing, adding a dependency.where-based queries if needed.belongsToMany with composite keys (e.g., for multi-tenant pivot tables)?Compoships trait/inheritance without disrupting existing model hierarchies?attach())? If so, has Compoships been benchmarked for these workloads?where clauses or manual joins for composite keys.Compoships (e.g., those with multi-column foreign keys).where-based relationships with Compoships syntax:
// Before
return $this->hasMany(Task::class)->where('team_id', $this->team_id);
// After
return $this->hasMany(Task::class, ['team_id', 'category_id'], ['team_id', 'category_id']);
belongsToMany relationships with composite keys first (highest impact).ComposhipsFactory trait.Awobaz\Compoships\Database\Eloquent\Relations\Pivot.with()), bulk operations (attach(), sync()), and existence queries (has(), whereHas()).DB::table() remain unaffected.where clauses may need updates if they rely on model attributes not yet loaded (e.g., during eager loading).hasMany, belongsTo, and belongsToMany with composite keys.attach(), sync(), and detach() for belongsToMany relationships.attach()).where clauses in relationships) and manual joins.attach() input shapes) in the team’s style guide.attach()/sync() operations.with() on parent models).attach()/sync() inputs to avoid InvalidUsageException.How can I help you explore Laravel packages today?