Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Sluggable Laravel Package

spatie/laravel-sluggable

Generate unique slugs for Eloquent models on create/update. Supports collision suffixes, translatable slugs, and customizable slug options. Includes self-healing URLs that keep old links working via slug+ID route keys with 308 redirects to the canonical URL.

View on GitHub
Deep Wiki
Context7

title: Using the Sluggable attribute weight: 2

This page documents every argument the #[Sluggable] attribute accepts. For setup, see Generating your first slug. For closures, translatable slugs, findBySlug(), and the other features that need the trait, see Using the HasSlug trait.

from

The source column. Pass a single column name to slugify its value, or an array of column names to join them with the slug separator before slugification. Defaults to 'name'. See Combining multiple source columns.

to

The column the generated slug is written to. Defaults to 'slug'.

separator

The character Str::slug uses to join words. Defaults to '-'.

language

Language code passed to Str::slug for transliteration of non-ASCII characters. Defaults to 'en'.

maxLength

Truncates the slug before uniqueness resolution runs. Defaults to 250. A uniqueness suffix may push the final value slightly past this limit.

unique

When true (the default), the package appends a numeric suffix (-1, -2, etc.) on collisions so the slug column stays unique. Set to false to allow duplicates. To start the suffix from a different number or always force a suffix, see Tuning the uniqueness suffix.

onCreate

When true (the default), a slug is generated as the model is first persisted. Set to false to leave the column untouched on create.

onUpdate

When true (the default), the slug is regenerated whenever the source field changes on an update. Set to false for permalinks that should stay fixed after the initial create.

preventOverwrite

When true, the package skips slug generation if the destination column already holds a value. Defaults to false. Useful when users provide their own slugs and the package should not stomp on them.

selfHealing

Enables self-healing route keys. Defaults to false. Requires the HasSlug trait on the same class. See Self-healing URLs.

selfHealingSeparator

The string placed between the slug and the identifier in the self-healing route key. Defaults to '-'. See Self-healing URLs.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle