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: Tuning the uniqueness suffix weight: 2

Slugs are unique by default. On a collision, the package appends a counter starting at 1 (for example this-is-an-example, this-is-an-example-1, this-is-an-example-2). Two builder methods change how that suffix is generated. They live on SlugOptions and are not available through the attribute.

Starting the counter at a different number

startSlugSuffixFrom() sets the first numeric suffix used on a collision.

SlugOptions::create()
    ->generateSlugsFrom('name')
    ->saveSlugsTo('slug')
    ->startSlugSuffixFrom(2);

Always append a suffix, even on the first record

useSuffixOnFirstOccurrence() adds a suffix even when the slug would otherwise be unique. Instead of this-is-an-example, this-is-an-example-1, you get this-is-an-example-1, this-is-an-example-2.

SlugOptions::create()
    ->generateSlugsFrom('name')
    ->saveSlugsTo('slug')
    ->useSuffixOnFirstOccurrence();

For a non-numeric or otherwise custom suffix, use the trait's usingSuffixGenerator(). See A custom suffix generator.

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