PHP Trait Spatie\Sluggable\HasSlug

Show file Open project: spatie/laravel-sluggable

Protected Properties

Property Type Description
$slugOptions SlugOptions

Public Methods

Method Description
generateSlug ( ) Handle setting slug on explicit request.
getSlugOptions ( ) : SlugOptions Get the options for generating the slug.

Protected Methods

Method Description
addSlug ( ) Add the slug to the model.
bootHasSlug ( ) Boot the trait.
generateNonUniqueSlug ( ) : string Generate a non unique slug for this record.
generateSlugOnCreate ( ) Handle adding slug on model creation.
generateSlugOnUpdate ( ) Handle adding slug on model update.
getSlugSourceString ( ) : string Get the string that should be used as base for the slug.
guardAgainstInvalidSlugOptions ( ) This function will throw an exception when any of the options is missing or invalid.
hasCustomSlugBeenUsed ( ) : boolean Determine if a custom slug has been saved.
makeSlugUnique ( string $slug ) : string Make the given slug unique.
otherRecordExistsWithSlug ( string $slug ) : boolean Determine if a record exists with the given slug.

Method Details

addSlug() protected method

Add the slug to the model.
protected addSlug ( )

bootHasSlug() protected static method

Boot the trait.
protected static bootHasSlug ( )

generateNonUniqueSlug() protected method

Generate a non unique slug for this record.
protected generateNonUniqueSlug ( ) : string
return string

generateSlug() public method

Handle setting slug on explicit request.
public generateSlug ( )

generateSlugOnCreate() protected method

Handle adding slug on model creation.
protected generateSlugOnCreate ( )

generateSlugOnUpdate() protected method

Handle adding slug on model update.
protected generateSlugOnUpdate ( )

getSlugOptions() abstract public method

Get the options for generating the slug.
abstract public getSlugOptions ( ) : SlugOptions
return SlugOptions

getSlugSourceString() protected method

Get the string that should be used as base for the slug.
protected getSlugSourceString ( ) : string
return string

guardAgainstInvalidSlugOptions() protected method

This function will throw an exception when any of the options is missing or invalid.

hasCustomSlugBeenUsed() protected method

Determine if a custom slug has been saved.
protected hasCustomSlugBeenUsed ( ) : boolean
return boolean

makeSlugUnique() protected method

Make the given slug unique.
protected makeSlugUnique ( string $slug ) : string
$slug string
return string

otherRecordExistsWithSlug() protected method

Determine if a record exists with the given slug.
protected otherRecordExistsWithSlug ( string $slug ) : boolean
$slug string
return boolean

Property Details

$slugOptions protected property

protected SlugOptions,Spatie\Sluggable $slugOptions
return SlugOptions