Eases using and generating slugs Laravel Eloquent models.
kduma/eloquent-sluggable is a Laravel package for eases using and generating slugs laravel eloquent models..
It currently has 2 GitHub stars and 875 downloads on Packagist (latest version v3.0.0).
Install it with composer require kduma/eloquent-sluggable.
Discover more Laravel packages by kduma
or browse all Laravel packages to compare alternatives.
Last updated
Eloquent trait for automatically generating unique slugs for Laravel models.
Full documentation: opensource.duma.sh/libraries/php/eloquent-sluggable
^8.3^13.0composer require kduma/eloquent-sluggable
use KDuma\Eloquent\Sluggable;
use KDuma\Eloquent\Attributes\HasSlug;
#[HasSlug(from: 'title', field: 'slug')]
class Post extends Model
{
use Sluggable;
}
Add a slug column to your migration:
$table->string('slug')->unique();
Slug is auto-generated on create. Find by slug with Post::whereSlug($slug).