Skip to main content

Crate laravel_sluggable

Crate laravel_sluggable 

Source
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 Hooks for a Sluggable model, calling creating and updating. A model with hooks of its own calls those two functions from them instead.

Structs§

InvalidSlugAttribute
SlugService::create_slug was given an attribute that isn’t one of the model’s slugs, and no settings: PHP’s InvalidArgumentException.
Slug
One slug column and its settings: an entry of the array that PHP’s sluggable() returns. Settings it doesn’t set come from SluggableConfig.
SlugMethod
A custom slug method, the method setting: called with the source text and the separator, it returns the slug instead of the slug engine.
SlugOptions
The settings of one slug, the PHP package’s merged config array: the model’s settings over SluggableConfig. Sluggable::with_unique_slug_constraints receives it.
SlugService
The PHP package’s SlugService.
SluggableConfig
The package’s settings: config/sluggable.php. A model’s Slug overrides any of them for one slug column, as the PHP package merges a model’s settings over the file.
SluggableServiceProvider
Registers the SluggableConfig section:
Slugify
The slug engine: cocur/slugify’s Slugify class.
SlugifyOptions
The options of cocur/slugify’s Slugify constructor: the slugEngineOptions setting.
UniqueSuffix
A custom suffix generator, the uniqueSuffix setting: called with the slug, the separator, the similar slugs and the firstUniqueSuffix, it returns the suffix to append.

Enums§

SlugSubject
What a slug is made from: the model being saved, or the columns a create is about to insert.

Traits§

SlugColumn
A column that holds a slug: a String or Option<String> column.
SlugSource
One source of a slug: a column, or a closure given with Slug::source_with.
Sluggable
A model with slugs: the PHP package’s Sluggable trait.
SluggableScopeHelpers
The PHP package’s SluggableScopeHelpers trait: the model’s primary slug, and finding a model by it. Implement it with an empty impl SluggableScopeHelpers for Post {}.
SourceValue
A value a slug can be made from. PHP joins the sources’ values with spaces, writing true and false as 1 and 0, and null as nothing.

Functions§

creating
Generates the slugs of a create: call it from your model’s Hooks::creating, as PHP’s observer does on saving.
updating
Regenerates the slugs of an update when needed: call it from your model’s Hooks::updating.