reedware/laravel-composite-relations
BelongsTo, HasOne, HasMany), excluding polymorphic or many-to-many composite relations (a potential blocker for some use cases).user_id + tenant_id or parent_id + category_id).WHERE clauses) but should not be significant for typical use cases.toSql() output may be harder to read).NULL composite keys, duplicate values).HasMany for a critical model).Schema::table('child_table', function (Blueprint $table) {
$table->unsignedBigInteger('user_id')->nullable();
$table->unsignedBigInteger('tenant_id')->nullable();
$table->unique(['user_id', 'tenant_id']);
});
public function user()
{
return $this->belongsTo(User::class)
->withCompositeKeys(['user_id', 'tenant_id']);
}
user_id.tenant_id).composer require reedware/laravel-composite-relations.config/app.php.HasMany).DB::enableQueryLog()).WHERE [col1]=? AND [col2]=?).NULL handling, duplicate keys).WHERE clauses.toSql(), ->getQuery()->toSql()).with()) will work but may generate complex SQL.remember()).AND conditions to queries, which may impact:
| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Composite key constraint violation | IntegrityConstraintViolation |
Add proper indexes/unique constraints. |
| Missing composite key in query | Silent failures or incorrect data | Validate queries with toSql(). |
| Package abandonment | Broken functionality | Fork the package if critical. |
| Poorly designed composite relations | Performance degradation | Benchmark and optimize indexes. |
| UI/API misalignment | Data display issues | Test serialization/deserialization. |
withCompositeKeys()).NULL values in composite keys.How can I help you explore Laravel packages today?