File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,7 +15,12 @@ export default class Product extends BaseModel {
1515
1616 @manyToMany ( ( ) => Transaction , {
1717 pivotTable : 'transaction_products' ,
18+ localKey : 'id' ,
19+ pivotForeignKey : 'product_id' ,
20+ relatedKey : 'id' ,
21+ pivotRelatedForeignKey : 'transaction_id' ,
1822 pivotColumns : [ 'quantity' ] ,
23+ pivotTimestamps : true ,
1924 } )
2025 declare transactions : ManyToMany < typeof Transaction >
2126
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ export default class Transaction extends BaseModel {
1515 @column ( { columnName : 'gateway' } )
1616 declare gatewayId : number | null
1717
18- @column ( )
18+ @column ( { columnName : 'external_id' } )
1919 declare externalId : string | null
2020
2121 @column ( )
@@ -24,7 +24,7 @@ export default class Transaction extends BaseModel {
2424 @column ( )
2525 declare amount : number
2626
27- @column ( )
27+ @column ( { columnName : 'card_last_numbers' } )
2828 declare cardLastNumbers : string | null
2929
3030 @belongsTo ( ( ) => Client )
@@ -35,6 +35,10 @@ export default class Transaction extends BaseModel {
3535
3636 @manyToMany ( ( ) => Product , {
3737 pivotTable : 'transaction_products' ,
38+ localKey : 'id' ,
39+ pivotForeignKey : 'transaction_id' ,
40+ relatedKey : 'id' ,
41+ pivotRelatedForeignKey : 'product_id' ,
3842 pivotColumns : [ 'quantity' ] ,
3943 pivotTimestamps : true ,
4044 } )
Original file line number Diff line number Diff line change @@ -5,10 +5,10 @@ export default class TransactionProduct extends BaseModel {
55 @column ( { isPrimary : true } )
66 declare id : number
77
8- @column ( )
8+ @column ( { columnName : 'transaction_id' } )
99 declare transactionId : number
1010
11- @column ( )
11+ @column ( { columnName : 'product_id' } )
1212 declare productId : number
1313
1414 @column ( )
You can’t perform that action at this time.
0 commit comments