mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-14 12:14:33 +01:00
Lint and update
This commit is contained in:
@@ -1,45 +1,43 @@
|
||||
import {HttpContextContract} from "@ioc:Adonis/Core/HttpContext";
|
||||
import Translation from "App/Models/Translation";
|
||||
import TranslationStoreValidator from "App/Validators/translation/TranslationStoreValidator";
|
||||
import TranslationUpdateValidator from "App/Validators/translation/TranslationUpdateValidator";
|
||||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||
import Translation from 'App/Models/Translation'
|
||||
import TranslationStoreValidator from 'App/Validators/translation/TranslationStoreValidator'
|
||||
import TranslationUpdateValidator from 'App/Validators/translation/TranslationUpdateValidator'
|
||||
|
||||
export default class TranslationsController {
|
||||
|
||||
public async index ({ response }: HttpContextContract) {
|
||||
public async index({ response }: HttpContextContract) {
|
||||
return response.status(200).send({
|
||||
translations: await Translation.query().orderBy('id', 'asc')
|
||||
translations: await Translation.query().orderBy('id', 'asc'),
|
||||
})
|
||||
}
|
||||
|
||||
public async store ({ request, response }: HttpContextContract) {
|
||||
public async store({ request, response }: HttpContextContract) {
|
||||
const data = await request.validate(TranslationStoreValidator)
|
||||
return response.status(200).send({
|
||||
translation: await Translation.create(data)
|
||||
translation: await Translation.create(data),
|
||||
})
|
||||
}
|
||||
|
||||
public async show ({ params, response }: HttpContextContract) {
|
||||
public async show({ params, response }: HttpContextContract) {
|
||||
return response.status(200).send({
|
||||
translation: await Translation.findOrFail(params.id)
|
||||
translation: await Translation.findOrFail(params.id),
|
||||
})
|
||||
}
|
||||
|
||||
public async update ({ request, params, response }: HttpContextContract) {
|
||||
public async update({ request, params, response }: HttpContextContract) {
|
||||
const translation = await Translation.findOrFail(params.id)
|
||||
const data = await request.validate(TranslationUpdateValidator)
|
||||
await translation.merge(data).save()
|
||||
|
||||
return response.status(200).send({
|
||||
translation
|
||||
translation,
|
||||
})
|
||||
}
|
||||
|
||||
public async destroy ({ response, params }: HttpContextContract) {
|
||||
public async destroy({ response, params }: HttpContextContract) {
|
||||
const translation = await Translation.findOrFail(params.id)
|
||||
await translation.delete()
|
||||
return response.status(200).send({
|
||||
message: 'Translation successfully deleted!'
|
||||
message: 'Translation successfully deleted!',
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user