From 026b91a99bb9c457ebe5d9358fa0c8a3588087f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Jos=C3=A9=20Carvalho=20de=20Mello?= Date: Tue, 2 Jun 2020 20:49:26 -0300 Subject: [PATCH] Update slug.md --- docs/v3.x/guides/slug.md | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/docs/v3.x/guides/slug.md b/docs/v3.x/guides/slug.md index 81aeeec298..7bf800b362 100644 --- a/docs/v3.x/guides/slug.md +++ b/docs/v3.x/guides/slug.md @@ -63,17 +63,15 @@ When it's done, you have to update the life cycle of the **Article** Content Typ const slugify = require('slugify'); module.exports = { - beforeSave: async model => { - if (model.title) { - model.slug = slugify(model.title); - } - }, - beforeUpdate: async model => { - if (model.getUpdate() && model.getUpdate().title) { - model.update({ - slug: slugify(model.getUpdate().title), - }); - } + lifecycles: { + beforeCreate: async (data) => { + if (data.title) { + data.slug = slugify(data.title); + } + }, + beforeUpdate: async (params, data) => { + data.slug = slugify(data.title); + }, }, }; ```