Skip to content

Refactor Join System #310

Description

@armanist

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.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

Fields

No fields configured for Task.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions