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
+6
View File
@@ -735,6 +735,9 @@
}
}
},
"slug": {
"type": "string"
},
"published_at": {
"type": "string",
"format": "date-time"
@@ -771,6 +774,9 @@
"user": {
"type": "string"
},
"slug": {
"type": "string"
},
"published_at": {
"type": "string",
"format": "date-time"
+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)
+3
View File
@@ -45,6 +45,9 @@
"user": {
"plugin": "users-permissions",
"model": "user"
},
"slug": {
"type": "string"
}
}
}