mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-14 20:19:26 +01:00
Lint and update
This commit is contained in:
@@ -1,46 +1,44 @@
|
||||
import {HttpContextContract} from "@ioc:Adonis/Core/HttpContext";
|
||||
import PostColor from "App/Models/PostColor";
|
||||
import PostColorStoreValidator from "App/Validators/postColor/PostColorStoreValidator";
|
||||
import PostColorUpdateValidator from "App/Validators/postColor/PostColorUpdateValidator";
|
||||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||
import PostColor from 'App/Models/PostColor'
|
||||
import PostColorStoreValidator from 'App/Validators/postColor/PostColorStoreValidator'
|
||||
import PostColorUpdateValidator from 'App/Validators/postColor/PostColorUpdateValidator'
|
||||
|
||||
export default class PostColorsController {
|
||||
|
||||
public async index ({ response }: HttpContextContract) {
|
||||
public async index({ response }: HttpContextContract) {
|
||||
return response.status(200).send({
|
||||
post_colors: await PostColor.all()
|
||||
post_colors: await PostColor.all(),
|
||||
})
|
||||
}
|
||||
|
||||
public async store ({ request, response }: HttpContextContract) {
|
||||
public async store({ request, response }: HttpContextContract) {
|
||||
const data = await request.validate(PostColorStoreValidator)
|
||||
const postColor = await PostColor.create(data)
|
||||
return response.status(200).send({
|
||||
post_color: postColor
|
||||
post_color: postColor,
|
||||
})
|
||||
}
|
||||
|
||||
public async show ({ params, response }: HttpContextContract) {
|
||||
public async show({ params, response }: HttpContextContract) {
|
||||
const postColor = await PostColor.findOrFail(params.id)
|
||||
return response.status(200).send({
|
||||
post_color: postColor
|
||||
post_color: postColor,
|
||||
})
|
||||
}
|
||||
|
||||
public async update ({ request, params, response }: HttpContextContract) {
|
||||
public async update({ request, params, response }: HttpContextContract) {
|
||||
const data = await request.validate(PostColorUpdateValidator)
|
||||
const postColor = await PostColor.findOrFail(params.id)
|
||||
await postColor.merge(data).save()
|
||||
return response.status(200).send({
|
||||
post_color: postColor
|
||||
post_color: postColor,
|
||||
})
|
||||
}
|
||||
|
||||
public async destroy ({ response, params }: HttpContextContract) {
|
||||
public async destroy({ response, params }: HttpContextContract) {
|
||||
const postColor = await PostColor.findOrFail(params.id)
|
||||
await postColor.delete()
|
||||
return response.status(200).send({
|
||||
message: 'PostColor successfully deleted!'
|
||||
message: 'PostColor successfully deleted!',
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user