Skip to content

Commit 62450c5

Browse files
chore: wip
1 parent 70de826 commit 62450c5

23 files changed

+73
-59
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import type { ManufacturerRequestType } from '@stacksjs/orm'
2+
import { Action } from '@stacksjs/actions'
3+
4+
import { products } from '@stacksjs/commerce'
5+
6+
import { response } from '@stacksjs/router'
7+
8+
export default new Action({
9+
name: 'Manufacturer Destroy',
10+
description: 'Manufacturer Destroy ORM Action',
11+
method: 'DELETE',
12+
async handle(request: ManufacturerRequestType) {
13+
const id = request.getParam('id')
14+
15+
await products.manufacturers.destroy(Number(id))
16+
17+
return response.json({
18+
message: 'Manufacturer deleted successfully',
19+
})
20+
},
21+
})

app/Actions/Commerce/ManufacturerIndexAction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default new Action({
99
description: 'Manufacturer Index ORM Action',
1010
method: 'GET',
1111
async handle() {
12-
const results = await products.manufacturer.fetchWithProductCount()
12+
const results = await products.manufacturers.fetchWithProductCount()
1313

1414
return response.json(results)
1515
},

app/Actions/Commerce/ManufacturerShowAction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default new Action({
1111
async handle() {
1212
const id = request.getParam('id')
1313

14-
const model = await products.manufacturer.fetchById(Number(id))
14+
const model = await products.manufacturers.fetchById(Number(id))
1515

1616
return response.json(model)
1717
},

app/Actions/Commerce/ManufacturerStoreAction.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import type { ManufacturerRequestType } from '@stacksjs/orm'
22
import { Action } from '@stacksjs/actions'
3-
3+
import { products } from '@stacksjs/commerce'
44
import { response } from '@stacksjs/router'
55

66
export default new Action({
77
name: 'Manufacturer Store',
88
description: 'Manufacturer Store ORM Action',
99
method: 'POST',
1010
async handle(request: ManufacturerRequestType) {
11-
await request.validate()
12-
const model = await Manufacturer.create(request.all())
11+
const model = await products.manufacturers.store(request)
1312

1413
return response.json(model)
1514
},

app/Actions/Commerce/PrintDeviceStoreAction.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default new Action({
1010
method: 'POST',
1111
async handle(request: PrintDeviceRequestType) {
1212
await request.validate()
13+
1314
const model = await devices.store(request)
1415

1516
return response.json(model)

app/Actions/Commerce/ProductItemIndexAction.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { Action } from '@stacksjs/actions'
2+
import { products } from '@stacksjs/commerce'
23
import { response } from '@stacksjs/router'
34

45
export default new Action({
56
name: 'ProductItem Index',
67
description: 'ProductItem Index ORM Action',
78
method: 'GET',
89
async handle() {
9-
const results = ProductItem.all()
10+
const results = await products.items.fetchAll()
1011

1112
return response.json(results)
1213
},

app/Actions/Commerce/ProductItemShowAction.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import type { ProductItemRequestType } from '@stacksjs/orm'
22
import { Action } from '@stacksjs/actions'
33

4+
import { products } from '@stacksjs/commerce'
45
import { response } from '@stacksjs/router'
56

67
export default new Action({
78
name: 'ProductItem Show',
89
description: 'ProductItem Show ORM Action',
910
method: 'GET',
11+
1012
async handle(request: ProductItemRequestType) {
1113
const id = request.getParam('id')
1214

13-
const model = await ProductItem.findOrFail(Number(id))
15+
const model = await products.items.fetchById(Number(id))
1416

1517
return response.json(model)
1618
},

app/Actions/Commerce/ProductItemStoreAction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import type { ProductItemRequestType } from '@stacksjs/orm'
22
import { Action } from '@stacksjs/actions'
33

4+
import { products } from '@stacksjs/commerce'
45
import { response } from '@stacksjs/router'
56

67
export default new Action({
78
name: 'ProductItem Store',
89
description: 'ProductItem Store ORM Action',
910
method: 'POST',
1011
async handle(request: ProductItemRequestType) {
11-
await request.validate()
12-
const model = await ProductItem.create(request.all())
12+
const model = await products.items.store(request)
1313

1414
return response.json(model)
1515
},
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { ManufacturerRequestType } from '@stacksjs/orm'
2+
import { Action } from '@stacksjs/actions'
3+
4+
import { products } from '@stacksjs/commerce'
5+
6+
import { response } from '@stacksjs/router'
7+
8+
export default new Action({
9+
name: 'ProductManufacturer Destroy',
10+
description: 'ProductManufacturer Destroy ORM Action',
11+
method: 'DELETE',
12+
async handle(request: ManufacturerRequestType) {
13+
const id = request.getParam('id')
14+
15+
await products.manufacturerss.destroy(Number(id))
16+
17+
return response.json({ message: 'Manufacturer deleted successfully' })
18+
},
19+
})

app/Actions/Commerce/ProductManufacturerIndexAction.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { Action } from '@stacksjs/actions'
2+
import { products } from '@stacksjs/commerce'
23
import { response } from '@stacksjs/router'
34

45
export default new Action({
56
name: 'ProductManufacturer Index',
67
description: 'ProductManufacturer Index ORM Action',
78
method: 'GET',
89
async handle() {
9-
const results = ProductManufacturer.all()
10+
const results = await products.manufacturerss.fetchAll()
1011

1112
return response.json(results)
1213
},

0 commit comments

Comments
 (0)