nova-sluggable icon indicating copy to clipboard operation
nova-sluggable copied to clipboard

Translatable slugs

Open sanneterpstra opened this issue 5 years ago • 1 comments

Is there an easy way to implement translatable slugs? I'm using the optimistdigital/nova-translatable package but this gives me an error on the keyup event.

sanneterpstra avatar Feb 18 '20 13:02 sanneterpstra

spatie/laravel-translatable stores everything in JSON field. So you must use that JSON field to generate slug from on your model.

public function getSlugOptions(): SlugOptions
{
    return SlugOptions::create()
        ->generateSlugsFrom('name->en')
        ->saveSlugsTo('slug');
}

I haven't tried optimistdigital/nova-translatable and I don't know how it wraps native fields. So you have to try that yourself. But, I know it works with spatie/nova-translatable package.

amad avatar May 25 '20 20:05 amad