Replies: 1 comment
-
This seems to work really well for me public function getSlugOptions(): SlugOptions
{
return SlugOptions::create()
->generateSlugsFrom(function () {
return collect([
$this->for->value,
$this->rooms > 0 ? $this->rooms.'-'.Str::plural('bedroom', $this->rooms) : null,
$this->showers > 0 ? $this->showers.'-'.Str::plural('bathroom', $this->showers) : null,
$this->propertyType->name,
'in',
$this->township ? $this->township->name : null,
$this->region ? $this->region->name : null,
])->filter()->implode('-');
})
->saveSlugsTo('slug');
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I need to generate the slug for
Subcategory
model with a prefix ofCategory
slug. I am not sure is it possible to achieve this ?somthing like this :
category-slug-subcategory-slug
Beta Was this translation helpful? Give feedback.
All reactions