mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-14 20:19:26 +01:00
24 lines
673 B
TypeScript
24 lines
673 B
TypeScript
import {HttpContextContract} from "@ioc:Adonis/Core/HttpContext";
|
|
import Profile from "App/Models/Profile";
|
|
import ProfileUpdateValidator from "App/Validators/profile/ProfileUpdateValidator";
|
|
|
|
export default class ProfilesController {
|
|
|
|
public async index ( { response }: HttpContextContract ) {
|
|
return response.status(200).send({
|
|
profile: await Profile.first()
|
|
})
|
|
}
|
|
|
|
public async update ( { response, request }: HttpContextContract ) {
|
|
const profile = await Profile.firstOrFail()
|
|
const data = await request.validate(ProfileUpdateValidator)
|
|
await profile.merge(data).save()
|
|
|
|
return response.status(200).send({
|
|
profile
|
|
})
|
|
}
|
|
|
|
}
|