mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-14 20:19:26 +01:00
Add unlike method
This commit is contained in:
@@ -36,17 +36,15 @@ export default class PostsController {
|
||||
}
|
||||
|
||||
public async unlike ({params, response}: HttpContextContract) {
|
||||
let post = await Post.findBy('slug', params.slug)
|
||||
let post = await Post.findByOrFail('slug', params.slug)
|
||||
|
||||
if (post) {
|
||||
await post.merge({
|
||||
likes: post.likes--
|
||||
}).save()
|
||||
return response.status(200).send({
|
||||
status: 200,
|
||||
post
|
||||
})
|
||||
}
|
||||
await post.merge({
|
||||
likes: post.likes--
|
||||
}).save()
|
||||
return response.status(200).send({
|
||||
status: 200,
|
||||
post
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user