Skip to content

Commit e7dc3d5

Browse files
chore: wip
1 parent 4569d80 commit e7dc3d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+20766
-5
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: 'Coupon Index',
6+
description: 'Coupon Index ORM Action',
7+
method: 'GET',
8+
async handle() {
9+
const results = Coupon.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 { CouponRequestType } from '@stacksjs/orm'
2+
import { Action } from '@stacksjs/actions'
3+
4+
import { response } from '@stacksjs/router'
5+
6+
export default new Action({
7+
name: 'Coupon Show',
8+
description: 'Coupon Show ORM Action',
9+
method: 'GET',
10+
async handle(request: CouponRequestType) {
11+
const id = request.getParam('id')
12+
13+
const model = await Coupon.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 { CouponRequestType } from '@stacksjs/orm'
2+
import { Action } from '@stacksjs/actions'
3+
4+
import { response } from '@stacksjs/router'
5+
6+
export default new Action({
7+
name: 'Coupon Store',
8+
description: 'Coupon Store ORM Action',
9+
method: 'POST',
10+
async handle(request: CouponRequestType) {
11+
await request.validate()
12+
const model = await Coupon.create(request.all())
13+
14+
return response.json(model)
15+
},
16+
})
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { CustomerRequestType } from '@stacksjs/orm'
2+
import { Action } from '@stacksjs/actions'
3+
4+
export default new Action({
5+
name: 'Customer Destroy',
6+
description: 'Customer Destroy ORM Action',
7+
method: 'DELETE',
8+
async handle(request: CustomerRequestType) {
9+
const id = request.getParam('id')
10+
11+
const model = await Customer.findOrFail(Number(id))
12+
13+
model.delete()
14+
15+
return 'Model deleted!'
16+
},
17+
})
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: 'Customer Index',
6+
description: 'Customer Index ORM Action',
7+
method: 'GET',
8+
async handle() {
9+
const results = Customer.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 { CustomerRequestType } from '@stacksjs/orm'
2+
import { Action } from '@stacksjs/actions'
3+
4+
import { response } from '@stacksjs/router'
5+
6+
export default new Action({
7+
name: 'Customer Show',
8+
description: 'Customer Show ORM Action',
9+
method: 'GET',
10+
async handle(request: CustomerRequestType) {
11+
const id = request.getParam('id')
12+
13+
const model = await Customer.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 { CustomerRequestType } from '@stacksjs/orm'
2+
import { Action } from '@stacksjs/actions'
3+
4+
import { response } from '@stacksjs/router'
5+
6+
export default new Action({
7+
name: 'Customer Store',
8+
description: 'Customer Store ORM Action',
9+
method: 'POST',
10+
async handle(request: CustomerRequestType) {
11+
await request.validate()
12+
const model = await Customer.create(request.all())
13+
14+
return response.json(model)
15+
},
16+
})
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { CustomerRequestType } from '@stacksjs/orm'
2+
import { Action } from '@stacksjs/actions'
3+
4+
import { response } from '@stacksjs/router'
5+
6+
export default new Action({
7+
name: 'Customer Update',
8+
description: 'Customer Update ORM Action',
9+
method: 'PATCH',
10+
async handle(request: CustomerRequestType) {
11+
await request.validate()
12+
13+
const id = request.getParam('id')
14+
const model = await Customer.findOrFail(Number(id))
15+
16+
const result = model.update(request.all())
17+
18+
return response.json(result)
19+
},
20+
})
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: 'GiftCard Index',
6+
description: 'GiftCard Index ORM Action',
7+
method: 'GET',
8+
async handle() {
9+
const results = GiftCard.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 { GiftCardRequestType } from '@stacksjs/orm'
2+
import { Action } from '@stacksjs/actions'
3+
4+
import { response } from '@stacksjs/router'
5+
6+
export default new Action({
7+
name: 'GiftCard Show',
8+
description: 'GiftCard Show ORM Action',
9+
method: 'GET',
10+
async handle(request: GiftCardRequestType) {
11+
const id = request.getParam('id')
12+
13+
const model = await GiftCard.findOrFail(Number(id))
14+
15+
return response.json(model)
16+
},
17+
})

0 commit comments

Comments
 (0)