mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-14 20:19:26 +01:00
21 lines
626 B
TypeScript
Executable File
21 lines
626 B
TypeScript
Executable File
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
|
import FormValidator from "App/Validators/FormValidator";
|
|
import Form from "App/Models/Form";
|
|
import FormConfirmation from "App/Mailers/FormConfirmation";
|
|
|
|
export default class FormsController {
|
|
|
|
public async send({ request, response }: HttpContextContract) {
|
|
const data = await request.validate(FormValidator)
|
|
|
|
await Form.create(data)
|
|
|
|
await new FormConfirmation(data.name, data.email).preview()
|
|
//todo send confirmation email + email to me
|
|
return response.status(200).send({
|
|
message: 'Form successfully received !'
|
|
})
|
|
}
|
|
|
|
}
|