Sluggable
trait Winter\Storm\Database\Traits\Sluggable
Methods
public static bootSluggable () : void
Boot the sluggable trait for a model.
Returns
void
public getSluggableSeparator () : string
Override the default slug separator.
Returns
string
public
setSluggedValue (string $slugAttribute, mixed $sourceAttributes, integer $maxLength = 175)
: string
Sets a single slug attribute value.
Parameters
| Property | Type | Description |
|---|---|---|
| $slugAttribute | string |
string
Attribute to populate with the slug. |
| $sourceAttributes | mixed |
mixed
Attribute(s) to generate the slug from. Supports dotted notation for relations. |
| $maxLength | integer |
integer
Maximum length for the slug not including the counter. |
Returns
string
The generated value.
public slugAttributes () : void
Adds slug attributes to the dataset, used before saving.
Returns
void
protected getSluggableSourceAttributeValue ($key) : mixed
Get an attribute relation value using dotted notation.
Eg: author.name
Parameters
| Property | Type | Description |
|---|---|---|
| $key | mixed |
mixed
|
Returns
mixed
protected getSluggableUniqueAttributeValue (string $name, value $value) : string
Ensures a unique attribute value, if the value is already used a counter suffix is added.
Parameters
| Property | Type | Description |
|---|---|---|
| $name | string |
string
The database column name. |
| $value | value |
value
The desired column value. |
Returns
string
A safe value that is unique.
protected newSluggableQuery () : Builder
Returns a query that excludes the current record if it exists Supports SoftDelete trait
Returns
Builder
← Previous page
Winter\Storm\Database\Traits\SimpleTree
Next page →
Winter\Storm\Database\Traits\SoftDelete
Copyright © 2025 Winter CMS