PHP Class Cviebrock\EloquentSluggable\Services\SlugService

Show file Open project: cviebrock/eloquent-sluggable Class Usage Examples

Protected Properties

Property Type Description
$model Illuminate\Database\Eloquent\Model;

Public Methods

Method Description
buildSlug ( string $attribute, array $config, boolean $force = null ) : null | string Build the slug for the given attribute of the current model.
createSlug ( Model | string $model, string $attribute, string $fromString, array $config = null ) : string Generate a unique slug for a given string.
getConfiguration ( array $overrides = [] ) : array Get the sluggable configuration for the current model, including default values where not specified.
setModel ( Model $model )
slug ( Model $model, boolean $force = false ) : boolean Slug the current model.

Protected Methods

Method Description
generateSlug ( string $source, array $config, string $attribute ) : string Generate a slug from the given source string.
generateSuffix ( string $slug, string $separator, Collection $list ) : string Generate a unique suffix for the given slug (and list of existing, "similar" slugs.
getExistingSlugs ( string $slug, string $attribute, array $config ) : Collection Get all existing slugs that are similar to the given slug.
getSlugEngine ( string $attribute ) : Slugify Return a class that has a slugify() method, used to convert strings into slugs.
getSlugSource ( mixed $from ) : string Get the source string for the slug.
makeSlugUnique ( string $slug, array $config, string $attribute ) : string Checks if the slug should be unique, and makes it so if needed.
needsSlugging ( string $attribute, array $config ) : boolean Determines whether the model needs slugging.
usesSoftDeleting ( ) : boolean Does this model use softDeleting?
validateSlug ( string $slug, array $config, string $attribute ) : string Checks that the given slug is not a reserved word.

Method Details

buildSlug() public method

Build the slug for the given attribute of the current model.
public buildSlug ( string $attribute, array $config, boolean $force = null ) : null | string
$attribute string
$config array
$force boolean
return null | string

createSlug() public static method

Generate a unique slug for a given string.
public static createSlug ( Model | string $model, string $attribute, string $fromString, array $config = null ) : string
$model Illuminate\Database\Eloquent\Model | string
$attribute string
$fromString string
$config array
return string

generateSlug() protected method

Generate a slug from the given source string.
protected generateSlug ( string $source, array $config, string $attribute ) : string
$source string
$config array
$attribute string
return string

generateSuffix() protected method

Generate a unique suffix for the given slug (and list of existing, "similar" slugs.
protected generateSuffix ( string $slug, string $separator, Collection $list ) : string
$slug string
$separator string
$list Illuminate\Support\Collection
return string

getConfiguration() public method

Get the sluggable configuration for the current model, including default values where not specified.
public getConfiguration ( array $overrides = [] ) : array
$overrides array
return array

getExistingSlugs() protected method

Get all existing slugs that are similar to the given slug.
protected getExistingSlugs ( string $slug, string $attribute, array $config ) : Collection
$slug string
$attribute string
$config array
return Illuminate\Support\Collection

getSlugEngine() protected method

Return a class that has a slugify() method, used to convert strings into slugs.
protected getSlugEngine ( string $attribute ) : Slugify
$attribute string
return Cocur\Slugify\Slugify

getSlugSource() protected method

Get the source string for the slug.
protected getSlugSource ( mixed $from ) : string
$from mixed
return string

makeSlugUnique() protected method

Checks if the slug should be unique, and makes it so if needed.
protected makeSlugUnique ( string $slug, array $config, string $attribute ) : string
$slug string
$config array
$attribute string
return string

needsSlugging() protected method

Determines whether the model needs slugging.
protected needsSlugging ( string $attribute, array $config ) : boolean
$attribute string
$config array
return boolean

setModel() public method

public setModel ( Model $model )
$model Illuminate\Database\Eloquent\Model

slug() public method

Slug the current model.
public slug ( Model $model, boolean $force = false ) : boolean
$model Illuminate\Database\Eloquent\Model
$force boolean
return boolean

usesSoftDeleting() protected method

Does this model use softDeleting?
protected usesSoftDeleting ( ) : boolean
return boolean

validateSlug() protected method

Checks that the given slug is not a reserved word.
protected validateSlug ( string $slug, array $config, string $attribute ) : string
$slug string
$config array
$attribute string
return string

Property Details

$model protected property

protected Model;,Illuminate\Database\Eloquent $model
return Illuminate\Database\Eloquent\Model;