Skip to content

Commit dde71e3

Browse files
chore: wip
1 parent d37a377 commit dde71e3

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

storage/framework/defaults/models/Payment.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default {
1313
useSearch: {
1414
displayable: ['id', 'order_id', 'customer_id', 'amount', 'method', 'status', 'date'],
1515
searchable: ['order_id', 'customer_id', 'reference_number'],
16-
sortable: ['date', 'amount', 'created_at'],
16+
sortable: ['amount', 'created_at'],
1717
filterable: ['method', 'status', 'date'],
1818
},
1919

@@ -29,7 +29,7 @@ export default {
2929
observe: true,
3030
},
3131

32-
belongsTo: ['Order', 'User'], // For order_id and customer_id
32+
belongsTo: ['Order', 'Customer'], // For order_id and customer_id
3333

3434
attributes: {
3535
amount: {

storage/framework/orm/src/models/Payment.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Generated, Insertable, RawBuilder, Selectable, Updateable } from '@stacksjs/database'
22
import type { Operator } from '@stacksjs/orm'
3+
import type { CustomerModel } from './Customer'
34
import type { OrderModel } from './Order'
4-
import type { UserModel } from './User'
55
import { randomUUIDv7 } from 'bun'
66
import { cache } from '@stacksjs/cache'
77
import { sql } from '@stacksjs/database'
@@ -10,14 +10,14 @@ import { dispatch } from '@stacksjs/events'
1010

1111
import { DB, SubqueryBuilder } from '@stacksjs/orm'
1212

13-
import Order from './Order'
13+
import Customer from './Customer'
1414

15-
import User from './User'
15+
import Order from './Order'
1616

1717
export interface PaymentsTable {
1818
id: Generated<number>
1919
order_id: number
20-
user_id: number
20+
customer_id: number
2121
amount: number
2222
method: string
2323
status: string
@@ -153,12 +153,12 @@ export class PaymentModel {
153153
return this.attributes.order
154154
}
155155

156-
get user_id(): number {
157-
return this.attributes.user_id
156+
get customer_id(): number {
157+
return this.attributes.customer_id
158158
}
159159

160-
get user(): UserModel | undefined {
161-
return this.attributes.user
160+
get customer(): CustomerModel | undefined {
161+
return this.attributes.customer
162162
}
163163

164164
get id(): number {
@@ -1816,12 +1816,12 @@ export class PaymentModel {
18161816
return model
18171817
}
18181818

1819-
async userBelong(): Promise<UserModel> {
1820-
if (this.user_id === undefined)
1819+
async customerBelong(): Promise<CustomerModel> {
1820+
if (this.customer_id === undefined)
18211821
throw new HttpError(500, 'Relation Error!')
18221822

1823-
const model = await User
1824-
.where('id', '=', this.user_id)
1823+
const model = await Customer
1824+
.where('id', '=', this.customer_id)
18251825
.first()
18261826

18271827
if (!model)
@@ -1899,8 +1899,8 @@ export class PaymentModel {
18991899

19001900
order_id: this.order_id,
19011901
order: this.order,
1902-
user_id: this.user_id,
1903-
user: this.user,
1902+
customer_id: this.customer_id,
1903+
customer: this.customer,
19041904
...this.customColumns,
19051905
}
19061906

0 commit comments

Comments
 (0)