Skip to content

Commit 6336ea4

Browse files
chore: wip
1 parent db5adbf commit 6336ea4

20 files changed

+495
-449
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Action } from '@stacksjs/actions'
2+
import { response } from '@stacksjs/router'
3+
4+
export default new Action({
5+
name: 'Manufacturer Index',
6+
description: 'Manufacturer Index ORM Action',
7+
method: 'GET',
8+
async handle() {
9+
const results = Manufacturer.all()
10+
11+
return response.json(results)
12+
},
13+
})
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { ManufacturerRequestType } from '@stacksjs/orm'
2+
import { Action } from '@stacksjs/actions'
3+
4+
import { response } from '@stacksjs/router'
5+
6+
export default new Action({
7+
name: 'Manufacturer Show',
8+
description: 'Manufacturer Show ORM Action',
9+
method: 'GET',
10+
async handle(request: ManufacturerRequestType) {
11+
const id = request.getParam('id')
12+
13+
const model = await Manufacturer.findOrFail(Number(id))
14+
15+
return response.json(model)
16+
},
17+
})
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { ManufacturerRequestType } from '@stacksjs/orm'
2+
import { Action } from '@stacksjs/actions'
3+
4+
import { response } from '@stacksjs/router'
5+
6+
export default new Action({
7+
name: 'Manufacturer Store',
8+
description: 'Manufacturer Store ORM Action',
9+
method: 'POST',
10+
async handle(request: ManufacturerRequestType) {
11+
await request.validate()
12+
const model = await Manufacturer.create(request.all())
13+
14+
return response.json(model)
15+
},
16+
})

storage/framework/core/commerce/types.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import type { GiftCardJsonResponse } from '../../orm/src/models/GiftCard'
1313
// Import the OrderTable type from the ORM
1414
import type { OrderJsonResponse, OrdersTable } from '../../orm/src/models/Order'
1515
import type { OrderItemModel } from '../../orm/src/models/OrderItem'
16-
import type { ProductReviewJsonResponse } from '../../orm/src/models/ProductReview'
1716
import type { ProductManufacturerJsonResponse } from '../../orm/src/models/ProductManufacturer'
17+
import type { ProductReviewJsonResponse } from '../../orm/src/models/ProductReview'
1818

1919
// Re-export the types
2020
export type {
@@ -267,22 +267,22 @@ export interface ProductReviewStats {
267267
export interface FetchProductManufacturersOptions {
268268
/** Page number for pagination */
269269
page?: number
270-
270+
271271
/** Number of items per page */
272272
limit?: number
273-
273+
274274
/** Field to sort by */
275275
sortBy?: 'manufacturer' | 'country' | 'created_at' | 'updated_at'
276-
276+
277277
/** Sort direction */
278278
sortDirection?: 'asc' | 'desc'
279-
279+
280280
/** Filter by country */
281281
country?: string
282-
282+
283283
/** Filter by featured status */
284284
featured?: boolean
285-
285+
286286
/** Search term to filter results */
287287
search?: string
288-
}
288+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export type ModelNames = 'Project' | 'SubscriberEmail' | 'AccessToken' | 'Team' | 'Subscriber' | 'Deployment' | 'Release' | 'User' | 'Post' | 'OrderItem' | 'FailedJob' | 'Customer' | 'ProductReview' | 'Product' | 'PaymentMethod' | 'PaymentTransaction' | 'Request' | 'GiftCard' | 'Order' | 'ProductManufacturer' | 'Coupon' | 'Transaction' | 'LoyaltyPoint' | 'Job' | 'Subscription' | 'PaymentProduct' | 'LoyaltyReward' | 'Error' | 'ProductCategory'
1+
export type ModelNames = 'Project' | 'SubscriberEmail' | 'AccessToken' | 'Team' | 'Subscriber' | 'Deployment' | 'Release' | 'User' | 'Post' | 'Manufacturer' | 'OrderItem' | 'FailedJob' | 'Customer' | 'ProductReview' | 'Product' | 'PaymentMethod' | 'PaymentTransaction' | 'Request' | 'GiftCard' | 'Order' | 'Coupon' | 'Transaction' | 'LoyaltyPoint' | 'Job' | 'Subscription' | 'PaymentProduct' | 'LoyaltyReward' | 'Error' | 'ProductCategory'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export type TableNames = 'projects' | 'subscriber_emails' | 'personal_access_tokens' | 'team_users' | 'teams' | 'subscribers' | 'deployments' | 'releases' | 'team_users' | 'users' | 'posts' | 'order_items' | 'failed_jobs' | 'customers' | 'product_reviews' | 'products' | 'payment_methods' | 'payment_transactions' | 'requests' | 'gift_cards' | 'orders' | 'product_manufacturers' | 'coupons' | 'transactions' | 'loyalty_points' | 'jobs' | 'subscriptions' | 'payment_products' | 'loyalty_rewards' | 'errors' | 'product_categories'
1+
export type TableNames = 'projects' | 'subscriber_emails' | 'personal_access_tokens' | 'team_users' | 'teams' | 'subscribers' | 'deployments' | 'releases' | 'team_users' | 'users' | 'posts' | 'manufacturers' | 'order_items' | 'failed_jobs' | 'customers' | 'product_reviews' | 'products' | 'payment_methods' | 'payment_transactions' | 'requests' | 'gift_cards' | 'orders' | 'coupons' | 'transactions' | 'loyalty_points' | 'jobs' | 'subscriptions' | 'payment_products' | 'loyalty_rewards' | 'errors' | 'product_categories'

storage/framework/defaults/models/ProductManufacturer.ts renamed to storage/framework/defaults/models/Manufacturer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import type { Model } from '@stacksjs/types'
22
import { schema } from '@stacksjs/validation'
33

44
export default {
5-
name: 'ProductManufacturer',
6-
table: 'product_manufacturers',
5+
name: 'Manufacturer',
6+
table: 'manufacturers',
77
primaryKey: 'id',
88
autoIncrement: false, // Using UUID instead of auto-increment
99

storage/framework/defaults/models/Product.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default {
2929
observe: true,
3030
},
3131

32-
belongsTo: ['ProductCategory', 'ProductManufacturer'],
32+
belongsTo: ['ProductCategory', 'Manufacturer'],
3333

3434
attributes: {
3535
name: {

storage/framework/orm/routes.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { route } from '@stacksjs/router'
22

3+
route.get('product-manufacturers', 'ManufacturerIndexOrmAction')
4+
5+
route.post('product-manufacturers', 'ManufacturerStoreOrmAction')
6+
7+
route.get('product-manufacturers/{id}', 'ManufacturerShowOrmAction')
8+
39
route.get('customers', 'CustomerIndexOrmAction')
410

511
route.post('customers', 'CustomerStoreOrmAction')
@@ -44,12 +50,6 @@ route.post('orders', 'OrderStoreOrmAction')
4450

4551
route.get('orders/{id}', 'OrderShowOrmAction')
4652

47-
route.get('product-manufacturers', 'ProductManufacturerIndexOrmAction')
48-
49-
route.post('product-manufacturers', 'ProductManufacturerStoreOrmAction')
50-
51-
route.get('product-manufacturers/{id}', 'ProductManufacturerShowOrmAction')
52-
5353
route.get('coupons', 'CouponIndexOrmAction')
5454

5555
route.post('coupons', 'CouponStoreOrmAction')

storage/framework/orm/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export { default as LoyaltyPoint } from './LoyaltyPoint'
1818

1919
export { default as LoyaltyReward } from './LoyaltyReward'
2020

21+
export { default as Manufacturer } from './Manufacturer'
22+
2123
export { default as Order } from './Order'
2224

2325
export { default as OrderItem } from './OrderItem'
@@ -34,8 +36,6 @@ export { default as Product } from './Product'
3436

3537
export { default as ProductCategory } from './ProductCategory'
3638

37-
export { default as ProductManufacturer } from './ProductManufacturer'
38-
3939
export { default as ProductReview } from './ProductReview'
4040

4141
export { default as Project } from './Project'

0 commit comments

Comments
 (0)