Sluggable: Clean URLs, one line away
Slugs for Eloquent, zero setup. Add protected $sluggable = 'title'; and Hello World becomes hello-world, then hello-world-2, or fill as many slug columns as you need with sluggable().
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.
A quick look
One property on the model, one macro in the migration, and slugs take care of themselves.
1use Illuminate\Database\Eloquent\Model; 2use Pharaonic\Laravel\Sluggable\Sluggable; 3 4class Post extends Model 5{ 6 use Sluggable; 7 8 protected $fillable = ['title']; 9 10 protected $sluggable = 'title'; // title -> slug11}12 13Post::create(['title' => 'Hello World'])->slug; // "hello-world"14Post::create(['title' => 'Hello World'])->slug; // "hello-world-2"15Post::findBySlug('hello-world'); // PostSluggable 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+ 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.