New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

aesircloud/sluggable

A Laravel package to automatically generate slugs for models
1,455

Larablocks Analysis

aesircloud/sluggable works with Laravel 12 and 13 (latest release 1.3.0, Nov 21, 2026).

Laravel 8 to 11 in earlier releases.

Recommendation checks

Solid choice

Solid choice: maintained and up to date, meets 2 of 4 checks; below the bar for Recommended on use.

  • Works with Laravel 13, the current version
  • Released in the last 12 months (Nov 21, 2026)
  • 1,123 downloads a month (needs 10,000)
  • 0 GitHub stars (needs 100)

State

Actively maintained
  • Last stable release: Nov 21, 2026.
  • 3 releases in the last 12 months.
  • First released: Jun 27, 2024.
  • Monthly downloads: 1,123.
  • 0 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Nov 26, 2026.

Install
composer require aesircloud/sluggable
Latest Version:1.3.0
PHP:^8.3
Laravel:12 · 13
Older releases:8 – 11
License:MIT
Last Updated:Nov 21, 2026
Links: GitHub  ·  Packagist
Maintainer: gregupton

Version 1.3 supports PHP 8.3–8.6. Existing APIs and framework support are retained.

Generate unique slugs when creating or updating Eloquent models

sluggable is a Laravel package that generates unique slugs for Eloquent models. It can be used to automatically generate slugs when creating or updating models, with flexible options controlled by both a config file and model-level properties.


Installation

You can install the package via Composer:

  composer require aesircloud/sluggable

Publish the configuration file

  php artisan vendor:publish --provider="AesirCloud\Sluggable\SluggableServiceProvider"

Usage

Add the Sluggable trait to your model:

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use AesirCloud\Sluggable\Traits\Sluggable;

class Post extends Model
{
    use Sluggable;

    protected $fillable = ['title', 'slug'];

    /**
     * Optionally override the default slug source field.
     *
     * By default, the package uses whatever is set in 'sluggable.source'
     * or falls back to 'name' on your model. Here, we explicitly use 'title'.
     */
    protected $slugSource = 'title';

    /**
     * If you want to allow the slug to be updated automatically when 'title' changes:
     */
    protected $slugUpdatable = true;

    /**
     * If you want a different slug column in your database table:
     */
    protected $slugColumn = 'url_slug';
}

2. Migrate the Slug Column

Ensure your table has a suitable column for the slug:

  php artisan make:migration add_slug_to_posts_table --table=posts
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('posts', function (Blueprint $table) {
            // Make sure it's unique or at least indexed if you rely on uniqueness.
            $table->string('slug')->unique()->after('title');
        });
    }

    public function down(): void
    {
        Schema::table('posts', function (Blueprint $table) {
            $table->dropColumn('slug');
        });
    }
};

3. Configuration Options

Open config/sluggable.php to see the available options. You can override any of these in your model by defining the corresponding property.

return [
    'source'     => 'name',
    'column'     => 'slug',
    'update'     => false,
    'max_length' => 255,
    'scopes'     => [], // e.g. ['category_id'] to scope uniqueness
];

  • source: The default field the slug is generated from if you don’t set $slugSource in the model.
  • column: The column to store the slug.
  • update: Set true to automatically regenerate a slug when the source field changes on update.
  • max_length: Truncates the slug (plus space for numeric suffixes) to this length if specified.
  • scopes: Array of columns to scope uniqueness (e.g., if you only want unique slugs per category_id).

4. Route Model Binding (Optional)

If you want to use the slug in your routes, you can override getRouteKeyName() in your model:

public function getRouteKeyName()
{
    return 'slug';
}

Then reference it in your routes:

Route::get('/posts/{post:slug}', function (App\Models\Post $post) {
    return $post;
});

Changelog

Please see CHANGELOG for more information what has changed recently.

Security

If you've found a bug regarding security please mail security@aesircloud.com instead of using the issue tracker.

LICENSE

The MIT License (MIT). Please see License file for more information.

Related Packages

mgboateng/eloquent-slug

Create elegant slugs in Laravel models with ease

333 3
bassam-nab/laravel-arabic-slug

laravel-arabic-slug.

6 1
sajawd-yq/eloquent-sluggable-persian

Easy creation of slugs for your Eloquent models in Laravel

96 3
cocur/slugify

Converts a string into a slug.

78,892,324 2,893
jellybool/translug

Translate Chinese And Then Make It Sluggable

47,533 145

Version History

Version Released PHP Laravel License
1.3.0 ^8.3 ^12.0|^13.0 MIT
1.2.1 ^8.4 ^12.0|^13.0 MIT
1.2.0 ^8.4 ^12.0|^13.0 MIT
1.1.5 ^8.4 ^12.0 MIT
1.1.4 ^8.4 ^12.0 MIT