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: Introduction weight: 1

This package generates a unique slug for any Eloquent model whenever it is created or updated. Add a #[Sluggable] attribute to the class and the package takes care of the rest.

use Spatie\Sluggable\Attributes\Sluggable;

#[Sluggable(from: 'title', to: 'slug')]
class Post extends Model
{
}

$post = Post::create(['title' => 'activerecord is awesome']);
$post->slug; // "activerecord-is-awesome"

Slugs are produced by Laravel's Str::slug helper, which lowercases and replaces spaces with a configurable separator.

Head to Generating your first slug for the migration, the model, and the route binding in one walkthrough.

On top of generation, this package also ships:

  • Self-healing URLs: route keys that combine the slug with the primary key so changing a slug never breaks existing links.
  • Translatable slugs: integration with spatie/laravel-translatable to store one slug per locale.
  • Overridable actions: swap the slug generator or the self-healing URL logic for your own class via a config file.
  • Laravel Boost skill: a bundled Boost skill that teaches AI assistants how to use this package. See Laravel Boost skill.

Self-healing URLs at a glance

Rename a post and its URL changes with it. Every bookmark, search result, and shared link pointing at the old URL now returns a 404.

Enable selfHealing and the route key becomes {slug}-{id}. The primary key resolves the model, so the slug can change without breaking lookups. Old URLs return a 308 redirect to the current one.

Read the full story in 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