mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-26 17:40:27 +01:00
Add unlike method
This commit is contained in:
@@ -36,17 +36,15 @@ export default class PostsController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async unlike ({params, response}: HttpContextContract) {
|
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({
|
||||||
await post.merge({
|
likes: post.likes--
|
||||||
likes: post.likes--
|
}).save()
|
||||||
}).save()
|
return response.status(200).send({
|
||||||
return response.status(200).send({
|
status: 200,
|
||||||
status: 200,
|
post
|
||||||
post
|
})
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user