Public methods

public static void bootSluggable()

Boot the sluggable trait for a model.

public string getSluggableSeparator()

Override the default slug separator.

public string setSluggedValue(string $slugAttribute, mixed $sourceAttributes, int $maxLength=175)

Sets a single slug attribute value.

  • string $slugAttribute - Attribute to populate with the slug.
  • mixed $sourceAttributes - Attribute(s) to generate the slug from. Supports dotted notation for relations.
  • int $maxLength - Maximum length for the slug not including the counter.

public void slugAttributes()

Adds slug attributes to the dataset, used before saving.

Protected methods

protected mixed getSluggableSourceAttributeValue($key)

Get an attribute relation value using dotted notation. Eg: author.name

  • $key

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

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

  • string $name - The database column name.
  • value $value - The desired column value.

protected Builder newSluggableQuery()

Returns a query that excludes the current record if it exists