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 Description
$slugAttribute
string

Attribute to populate with the slug.

$sourceAttributes
mixed

Attribute(s) to generate the slug from. Supports dotted notation for relations.

$maxLength
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 Description
$key
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 Description
$name
string

The database column name.

$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
Copyright © 2024 Winter CMS