Documentation

Sluggable

Table of Contents

bootSluggable()  : void
Boot the sluggable trait for a model.
getSluggableSeparator()  : string
Override the default slug separator.
setSluggedValue()  : string
Sets a single slug attribute value.
slugAttributes()  : void
Adds slug attributes to the dataset, used before saving.
getSluggableSourceAttributeValue()  : mixed
Get an attribute relation value using dotted notation.
getSluggableUniqueAttributeValue()  : string
Ensures a unique attribute value, if the value is already used a counter suffix is added.
newSluggableQuery()  : Builder
Returns a query that excludes the current record if it exists

Methods

bootSluggable()

Boot the sluggable trait for a model.

public static bootSluggable() : void
Return values
void

getSluggableSeparator()

Override the default slug separator.

public getSluggableSeparator() : string
Return values
string

setSluggedValue()

Sets a single slug attribute value.

public setSluggedValue(string $slugAttribute, mixed $sourceAttributes[, int $maxLength = 175 ]) : string
Parameters
$slugAttribute : string

Attribute to populate with the slug.

$sourceAttributes : mixed

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

$maxLength : int = 175

Maximum length for the slug not including the counter.

Return values
string

The generated value.

slugAttributes()

Adds slug attributes to the dataset, used before saving.

public slugAttributes() : void
Return values
void

getSluggableSourceAttributeValue()

Get an attribute relation value using dotted notation.

protected getSluggableSourceAttributeValue(mixed $key) : mixed

Eg: author.name

Parameters
$key : mixed
Return values
mixed

getSluggableUniqueAttributeValue()

Ensures a unique attribute value, if the value is already used a counter suffix is added.

protected getSluggableUniqueAttributeValue(string $name, value $value) : string
Parameters
$name : string

The database column name.

$value : value

The desired column value.

Return values
string

A safe value that is unique.

newSluggableQuery()

Returns a query that excludes the current record if it exists

protected newSluggableQuery() : Builder
Return values
Builder

Search results