Summary
Refactor and unify the way joinTo() and joinThrough() work across Quantum's database adapters (SleekDB, Idiorm, etc.) by introducing a declarative relations() system inside models. This will improve clarity, consistency, and maintainability of model relationships.
Objectives
- Replace legacy
$foreignKeys array with a relations() method in each model.
- Introduce/refine
joinTo() and joinThrough() methods to resolve relationships based on relations().
- Support chainable joins (e.g., User → UserEvent → Event) with clear control.
- Ensure join behavior works consistently across all supported adapters.
Design Notes
relations() format
Each model defines its foreign key relations like:
public function relations(): array
{
return [
RelatedModel::class => [
'local_key' => 'id',
'foreign_key' => 'user_id'
]
];
}
All relevant unit tests need to be updated.
Summary
Refactor and unify the way
joinTo()andjoinThrough()work across Quantum's database adapters (SleekDB,Idiorm, etc.) by introducing a declarativerelations()system inside models. This will improve clarity, consistency, and maintainability of model relationships.Objectives
$foreignKeysarray with arelations()method in each model.joinTo()andjoinThrough()methods to resolve relationships based onrelations().Design Notes
relations()formatEach model defines its foreign key relations like:
All relevant unit tests need to be updated.