mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-31 11:57:50 +01:00
Add unlike method
This commit is contained in:
@@ -36,9 +36,8 @@ 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()
|
||||||
@@ -47,6 +46,5 @@ export default class PostsController {
|
|||||||
post
|
post
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user