Twill is an open source CMS toolkit for Laravel that helps developers rapidly create a custom admin console that is intuitive, powerful and flexible. Chat with us on Discord at https://discord.gg/cnWk7EFv8R.
When duplicating a model with the duplicate feature, the slug is not created, resulting in routing issues, when saving a model outside of twill, the slug is also not created
This is what I'm doing to fix both problems
public function handleSlugsOnSave(): void
{
if (empty($this->twillSlugData)) {
$this->twillSlugData = array_filter($this->getSlugParams(), fn ($params) => ! empty($params['slug']));
foreach ($this->twillSlugData as &$datum) {
$datum['active'] ??= true;
}
}
$this->originalHandleSlugsOnSave();
}
I'm wondering why the slug handling is coded like this
if ($this->twillSlugData === []) { // Why return here?
return;
}
foreach (getLocales() as $locale) {
$this->disableLocaleSlugs($locale);
}
// This means this condition is useless
$slugParams = $this->twillSlugData !== [] ? $this->twillSlugData : $this->getSlugParams();
Seems both those lines where added in the same PR https://github.com/area17/twill/pull/1897, and it wasn't a case of the first return was added later to fix some issue
Description
When duplicating a model with the duplicate feature, the slug is not created, resulting in routing issues, when saving a model outside of twill, the slug is also not created
This is what I'm doing to fix both problems
I'm wondering why the slug handling is coded like this
Seems both those lines where added in the same PR https://github.com/area17/twill/pull/1897, and it wasn't a case of the first return was added later to fix some issue