@@ -3,10 +3,12 @@ import type { CheckoutLineItem, CheckoutOptions, StripeCustomerOptions } from '@
3
3
import type { DeploymentModel } from './Deployment'
4
4
import type { PaymentMethodModel } from './PaymentMethod'
5
5
import type { PostModel } from './Post'
6
+ import type { SubscriberModel } from './Subscriber'
6
7
import type { SubscriptionModel } from './Subscription'
7
8
import type { TransactionModel } from './Transaction'
8
9
import { randomUUIDv7 } from 'bun'
9
10
import { cache } from '@stacksjs/cache'
11
+
10
12
import { sql } from '@stacksjs/database'
11
13
12
14
import { HttpError , ModelNotFoundException } from '@stacksjs/error-handling'
@@ -17,8 +19,6 @@ import { DB, SubqueryBuilder } from '@stacksjs/orm'
17
19
18
20
import { manageCharge , manageCheckout , manageCustomer , manageInvoice , managePaymentMethod , manageSetupIntent , manageSubscription , manageTransaction , type Stripe } from '@stacksjs/payments'
19
21
20
- import Subscriber from './Subscriber'
21
-
22
22
import Team from './Team'
23
23
24
24
export interface UsersTable {
@@ -105,6 +105,10 @@ export class UserModel {
105
105
this . hasSaved = false
106
106
}
107
107
108
+ get subscriber ( ) : SubscriberModel | undefined {
109
+ return this . attributes . subscriber
110
+ }
111
+
108
112
get deployments ( ) : DeploymentModel [ ] | undefined {
109
113
return this . attributes . deployments
110
114
}
@@ -1517,20 +1521,6 @@ export class UserModel {
1517
1521
. execute ( )
1518
1522
}
1519
1523
1520
- async subscriber ( ) {
1521
- if ( this . id === undefined )
1522
- throw new HttpError ( 500 , 'Relation Error!' )
1523
-
1524
- const model = Subscriber
1525
- . where ( 'user_id' , '=' , this . id )
1526
- . first ( )
1527
-
1528
- if ( ! model )
1529
- throw new HttpError ( 500 , 'Model Relation Not Found!' )
1530
-
1531
- return model
1532
- }
1533
-
1534
1524
async userTeams ( ) {
1535
1525
if ( this . id === undefined )
1536
1526
throw new HttpError ( 500 , 'Relation Error!' )
0 commit comments