sluggable-development

Installation
SKILL.md

Sluggable development

Use this skill when adding slug generation to an Eloquent model with spatie/laravel-sluggable. The package writes a slug into a configurable column whenever the model is created or updated, keeps slugs unique, and can turn the resulting route key into a self-healing URL that tolerates slug changes.

Picking a configuration style

  • #[Sluggable] attribute: place it on the class. A wildcard Eloquent event listener in the package's service provider picks it up. Use this for most models.
  • HasSlug trait + getSlugOptions(): use when you need any of these features (callables for generateSlugsFrom, closures for extraScope or skipGenerateWhen, custom suffix generators, translatable slugs, findBySlug(), or self-healing URLs).

If both are present on a model, the trait wins and the attribute is ignored.

Making a field sluggable with the attribute

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Spatie\Sluggable\Attributes\Sluggable;
Installs
2
GitHub Stars
1.6K
First Seen
May 26, 2026
sluggable-development — spatie/laravel-sluggable