Single- and multi-language (json/jsonb locale-map) slugs for Eloquent: multiple columns per model, scoped per-locale uniqueness with engine-native indexes, locale-aware route binding, SEO slug history — native, zero third-party deps.
roundly-consulting/sluggable-for-laravel is a Laravel package for single- and multi-language (json/jsonb locale-map) slugs for eloquent: multiple columns per model, scoped per-locale uniqueness with engine-native indexes, locale-aware route binding, seo slug history — native, zero third-party deps..
It currently has 5 GitHub stars and 493 downloads on Packagist (latest version 1.1.3).
Install it with composer require roundly-consulting/sluggable-for-laravel.
Discover more Laravel packages by roundly-consulting
or browse all Laravel packages to compare alternatives.
Last updated
Single- and multi-language slugs for Eloquent: plain string slug columns and JSON locale-map
columns, scoped per-locale uniqueness backed by engine-native unique indexes, locale-aware route
model binding, validation rules and an optional slug history with 301 redirects. With the
defaults, ordinary input slugs exactly like Str::slug(), so adopting it keeps the slugs you
already have.
Requires PHP 8.4 and Laravel 12 or 13. Supported databases: PostgreSQL 12+ and MySQL 8.0.23+ / MariaDB 10.3.3+ (SQLite 3.38+ for tests). SQL Server is not supported.
composer require roundly-consulting/sluggable-for-laravel
Add the trait (zero config: slug is generated from name) and the column:
use Illuminate\Database\Eloquent\Model;
use RoundlyConsulting\Sluggable\Concerns\HasSlug;
use RoundlyConsulting\Sluggable\Contracts\Sluggable;
final class Clinic extends Model implements Sluggable
{
use HasSlug;
protected $fillable = ['name', 'slug'];
}
// in the migration
$table->slug(); // string('slug', 255)
$table->uniqueSlug(); // its unique index
Every save gets a unique slug, and it stays put when the name changes, so links never break:
use RoundlyConsulting\Sluggable\Facades\Slugs;
Clinic::create(['name' => 'Happy Paws'])->slug; // "happy-paws"
Clinic::create(['name' => 'Happy Paws'])->slug; // "happy-paws-2"
Route::get('/clinics/{clinic:slug}', ShowClinic::class);
Slugs::regenerate($clinic); // recompute from the new name and save
Slugs::slugify('Žltý kôň @ home', language: 'sk'); // "zlty-kon-at-home"
The full documentation — configuration, every feature and its API, and testing — lives on our website: roundly-consulting.com/open-source/docs/sluggable-for-laravel
Release notes are in CHANGELOG.md. To contribute, see the contributing guide.
This package is free and open source, built and maintained by Roundly Consulting. If it saves you time, please consider supporting our open-source work — a one-time donation, a monthly pledge on Patreon or a crypto donation helps fund maintenance, new features and new packages.
The MIT License (MIT). See LICENSE.md.