v0.3.2
Bug Fixes
BelongsToMany eager loading always returned an empty array.
When using Model.with(['relation']) on many-to-many relationships, the returned collection was always empty even when there were existing records in the pivot table.
Root Cause: The eager load flow executed get() before match(). The get() method moved the column pivot_ from _attributes into a PivotRecord (and deleted it from _attributes). When match() subsequently executed, it attempted to read attributes['pivot'] — which was already undefined — and therefore no model could be associated with its parent.
Correction: match() now reads the FK directly from the PivotRecord:
// antes
const fk = (related as any)._attributes[`pivot_${this.foreignPivotKey}`]; // undefined
// depois
const pivot = (related as any)._relations[this._pivotAlias] as PivotRecord;
const fk = pivot?.get(this.foreignPivotKey); // ✓