Looking to hire Laravel developers? Try LaraJobs

sluggable-for-laravel maintained by roundly-consulting

Description
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.
Last update
2026/10/03 19:55 (dev-main)
License
Downloads
1

Comments
comments powered by Disqus

Sluggable for Laravel

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.

Installation

Requires PHP 8.4 and Laravel 12 or 13. The unique-index DDL needs PostgreSQL 12+, MySQL 8.0.23+ / MariaDB 10.3.3+ or SQLite 3.38+; generation and querying work on every Laravel driver.

composer require roundly-consulting/sluggable-for-laravel

Usage

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"

Documentation

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.

Support our work

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.

License

The MIT License (MIT). See LICENSE.md.