Skip to content
Laravel Packagev13.xMIT License1K+ downloads

Sluggable: Clean URLs, one line away

Slugs for Eloquent, zero setup. Add #[Slug(source: 'title')] to your model using the Sluggable trait and Hello World becomes hello-world, then hello-world-2. Define multiple slug columns with repeatable attributes or sluggable(). Existing property and callable source configuration stays supported.

$composer require pharaonic/laravel-sluggable

Compatibility

Each line is released for the versions in its row, read from that release's composer.json. Pick the line that matches your project; a combination not listed isn't supported. Find the right line of every package for your project.

LineLatest releasePHPLaravelStatusDocs
v13.xv13.1.0 Oct 27, 20268.3 – 8.513Current Docs: Read the v13.x docs
v12.xv12.2.0 Oct 27, 20268.2 – 8.512Maintained Docs: Read the v12.x docs
v11.xv11.2.0 Oct 27, 20268.2 – 8.411MaintainedLaravel 11 no longer gets security fixes Docs: Read the v11.x docs
v10.xv10.1.0 Oct 27, 20268.1 – 8.310MaintainedLaravel 10 no longer gets security fixes Docs: Read the v10.x docs
v9.xv9.1.0 Oct 27, 20268.0 – 8.29MaintainedLaravel 9 no longer gets security fixes Docs: Read the v9.x docs
v8.xv8.1.0 Oct 27, 20268.0 – 8.18MaintainedLaravel 8 no longer gets security fixes Docs: Read the v8.x docs
v7.xv7.1.0 Oct 27, 20268.07MaintainedLaravel 7 no longer gets security fixes Docs: Read the v7.x docs
v6.xv6.1.0 Oct 27, 20268.06MaintainedLaravel 6 no longer gets security fixes Docs: Read the v6.x docs

Maintenance

Latest release
v13.1.0
Oct 27, 2026 (3 weeks ago)
Released lines
8
documented lines with a release; see compatibility
CI on develop
Not available right now
GitHub Actions status

From the package's releases and its GitHub Actions. A passing run means the test suite passed on develop, on every PHP version it supports; it isn't a security review, and each release line has its own runs on GitHub. Checked hourly.

A quick look

One attribute on the model, one macro in the migration, and slugs take care of themselves.

app/Models/Post.php
1use Illuminate\Database\Eloquent\Model;
2use Pharaonic\Laravel\Sluggable\Sluggable;
3use Pharaonic\Laravel\Sluggable\Attributes\Slug;
4 
5#[Slug(source: 'title')]
6class Post extends Model
7{
8 use Sluggable;
9 
10 protected $fillable = ['title'];
11}
12 
13Post::create(['title' => 'Hello World'])->slug; // "hello-world"
14Post::create(['title' => 'Hello World'])->slug; // "hello-world-2"
15Post::findBySlug('hello-world'); // Post
Key Features

Everything you need for model slugs

Add the trait, name the source column, and every new record gets a unique slug.

One-Line Setup

Add protected $sluggable = 'title'; and the slug column fills itself on create.

Unlimited Slug Columns

Return column => source from sluggable() to fill slug, seo_slug and more, independently.

Callable Sources

Build a slug from a relation, an accessor or any computed value with fn ($model) => ....

Always Unique

Collisions become hello-2, hello-3, found with one query per column and within max_length.

Manual Slugs Respected

A slug you set yourself is never overwritten, and existing slugs stay stable unless you enable on_update.

Unicode & ASCII

Keeps Arabic and other scripts by default, or transliterates to ASCII with one config switch.

FAQ

Sluggable Questions

Quick answers about installing and using Sluggable.

What is Sluggable?

Unique slugs for Eloquent models. One property for the common case, any number of slug columns when you need more. It's a free, open-source Laravel package by Pharaonic.

How do I install Sluggable?

Run composer require pharaonic/laravel-sluggable in your project's root directory.

What does Sluggable require?

The latest release requires PHP 8.3 – 8.5 and Laravel 13.

Can a model have more than one slug?

Yes. Define a sluggable() method that returns column => source pairs, such as 'slug' => 'title' and 'seo_slug' => 'seo_title'. There's no limit, and each column is generated and kept unique on its own.

Can a slug come from a relation?

Yes, through a callable source: 'category_slug' => fn ($model) => $model->category?->name ?? ''. A plain string such as 'category.name' is always read as a direct attribute, never as a relation path.

Will my slug change when I edit the title?

Not by default. on_update is false, so links stay stable. Enable it globally or per slug to regenerate the slug when its source changes. A slug you set yourself is never overwritten.

Does it support Arabic and other non-Latin titles?

Yes. Slugs keep Unicode letters by default (مرحبا-بالعالم). Set ascii_only to true to transliterate them to ASCII instead.

Is Sluggable free to use?

Yes. Sluggable is open source under the MIT license, so you can use it in personal and commercial projects.

Where can I find the Sluggable documentation?

Read the Sluggable documentation for setup, configuration, and usage examples.

How do I report a bug or contribute to Sluggable?

Open an issue or a pull request on GitHub, or ask in the Pharaonic Discord.

Ready to dig in?

Read the full documentation for installation, configuration, the $sluggable property, multiple slug columns, callable sources, per-slug options, unique suffixes and maximum length, update behavior, the migration macro, the @slug Blade directive, and real-world examples.