Search by

roundly-consulting / sluggable-for-laravel

mihaliak

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.

Package info

github.com/roundly-consulting/sluggable-for-laravel

pkg:composer/roundly-consulting/sluggable-for-laravel

Fund package maintenance!

Patreon

Statistics

Installs: 37

Dependents: 4

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-10-03 17:55 UTC

This package is auto-updated.

Last update: 2026-10-03 18:04:43 UTC


README

Sluggable for Laravel — Roundly open source

Latest release Tests Code style Donate Patreon Crypto

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.

Donate to Roundly open source Become a patron on Patreon Donate crypto: BTC, ETH, BNB or SOL

License

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