### Install Sluggable for Laravel via Composer Source: https://github.com/roundly-consulting/sluggable-for-laravel/blob/main/README.md Install the package using Composer. Requires PHP 8.4 and Laravel 12 or 13. Supported databases: PostgreSQL 12+, MySQL 8.0.23+/MariaDB 10.3.3+, SQLite 3.38+ for tests. SQL Server is not supported. ```bash composer require roundly-consulting/sluggable-for-laravel ``` -------------------------------- ### Generate and use slugs Source: https://github.com/roundly-consulting/sluggable-for-laravel/blob/main/README.md Shows how slugs are generated on save, how to use them in routes, and how to regenerate or slugify manually. Slugs are unique and remain unchanged when the name changes. ```php 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" ``` -------------------------------- ### Add HasSlug trait and slug column Source: https://github.com/roundly-consulting/sluggable-for-laravel/blob/main/README.md Add the HasSlug trait to a model and define the slug column in the migration. The trait generates a slug from the 'name' attribute by default. The migration uses the slug() and uniqueSlug() column types. ```php 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 ```