Add slug to awtis

This commit is contained in:
Cédric FAMIBELLE-PRONZOLA
2022-05-10 22:01:40 +04:00
parent 75f8ab7d3d
commit 89ab55ec6d
6 changed files with 31 additions and 2 deletions
+8
View File
@@ -19,6 +19,14 @@ const jwennAwtisEpiId = async id => {
module.exports = {
lifecycles: {
beforeUpdate: async (params, data) => {
if (!data.slug) {
data.slug = slugify(data.alias, {lower: true, remove: /[*#+~.()'"!:@]/g})
}
},
beforeCreate: async data => {
data.slug = slugify(data.alias, {lower: true, remove: /[*#+~.()'"!:@]/g})
},
afterUpdate: async (params, data) => {
const {id} = data
const awtis = await jwennAwtisEpiId(id)