Skip to content

Commit d657145

Browse files
committed
feat: refactor PivotModel to extend Model and initialize attributes correctly
1 parent 7641154 commit d657145

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/Model.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -627,9 +627,9 @@ export abstract class Model<
627627
this: new (attributes: Record<string, unknown>) => TModel,
628628
attributes: Record<string, unknown>
629629
): TModel {
630-
const model = new this(attributes)
631-
; (model as unknown as Model).syncOriginal()
632-
; (model as unknown as Model).syncChanges({})
630+
const model = new this(attributes);
631+
(model as unknown as Model).syncOriginal();
632+
(model as unknown as Model).syncChanges({})
633633

634634
return model
635635
}

src/PivotModel.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Model } from './Model'
2+
13
/**
24
* Base pivot class that all pivot models should extend.
35
*
@@ -6,8 +8,8 @@
68
* @author Legacy (3m1n3nc3)
79
* @since 2.0.0-next.18
810
*/
9-
export class PivotModel {
10-
constructor(attributes: Record<string, unknown> = {}) {
11-
Object.assign(this, attributes)
11+
export class PivotModel extends Model {
12+
constructor(protected readonly attributes: Record<string, unknown> = {}) {
13+
super(attributes)
1214
}
1315
}

0 commit comments

Comments
 (0)