Expand description
Easy creation of slugs for your Laravel Rust models: a port of cviebrock/eloquent-sluggable.
Slugs are made by a port of cocur/slugify with its own transliteration rules, so they match the PHP package’s. See the README for the guide.
Macros§
- sluggable_
hooks - Implements
Hooksfor aSluggablemodel, callingcreatingandupdating. A model with hooks of its own calls those two functions from them instead.
Structs§
- Invalid
Slug Attribute SlugService::create_slugwas given an attribute that isn’t one of the model’s slugs, and no settings: PHP’sInvalidArgumentException.- Slug
- One slug column and its settings: an entry of the array that PHP’s
sluggable()returns. Settings it doesn’t set come fromSluggableConfig. - Slug
Method - A custom slug method, the
methodsetting: called with the source text and the separator, it returns the slug instead of the slug engine. - Slug
Options - The settings of one slug, the PHP package’s merged config array: the model’s settings over
SluggableConfig.Sluggable::with_unique_slug_constraintsreceives it. - Slug
Service - The PHP package’s
SlugService. - Sluggable
Config - The package’s settings:
config/sluggable.php. A model’sSlugoverrides any of them for one slug column, as the PHP package merges a model’s settings over the file. - Sluggable
Service Provider - Registers the
SluggableConfigsection: - Slugify
- The slug engine: cocur/slugify’s
Slugifyclass. - Slugify
Options - The options of cocur/slugify’s
Slugifyconstructor: theslugEngineOptionssetting. - Unique
Suffix - A custom suffix generator, the
uniqueSuffixsetting: called with the slug, the separator, the similar slugs and thefirstUniqueSuffix, it returns the suffix to append.
Enums§
- Slug
Subject - What a slug is made from: the model being saved, or the columns a create is about to insert.
Traits§
- Slug
Column - A column that holds a slug: a
StringorOption<String>column. - Slug
Source - One source of a slug: a column, or a closure given with
Slug::source_with. - Sluggable
- A model with slugs: the PHP package’s
Sluggabletrait. - Sluggable
Scope Helpers - The PHP package’s
SluggableScopeHelperstrait: the model’s primary slug, and finding a model by it. Implement it with an emptyimpl SluggableScopeHelpers for Post {}. - Source
Value - A value a slug can be made from. PHP joins the sources’ values with spaces, writing
trueandfalseas1and0, andnullas nothing.