Automatically generate URL-friendly slugs for Eloquent models in Laravel.
Eloquent-Sluggable is a Laravel package that automatically generates URL-friendly slugs for Eloquent models. It transforms attributes like titles into SEO-optimized strings (e.g., 'My Blog Post' becomes 'my-blog-post') and ensures uniqueness by appending suffixes when needed. The package handles slug creation, updates, and validation with minimal setup, streamlining the process of creating readable URLs for web resources.
Laravel developers building applications that require SEO-friendly URLs, such as blogs, e-commerce sites, or content management systems. It's ideal for those using Eloquent models and wanting automated, consistent slug management without manual intervention.
Developers choose Eloquent-Sluggable for its deep integration with Laravel's Eloquent ORM, out-of-the-box uniqueness handling, and extensive customization options. Unlike manual slug implementations, it reduces boilerplate code, ensures URL consistency, and supports advanced features like multi-attribute sources, event hooks, and language-specific slugging rules.
Easy creation of slugs for your Eloquent models in Laravel
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Tightly hooks into Laravel's Eloquent ORM, automatically generating slugs on model events like 'saving' or 'saved', eliminating manual slug management as described in the 'When Is A Model Slugged?' section.
Automatically appends incremental suffixes (e.g., -1, -2) to prevent duplicate slugs when 'unique' is enabled, with configurable options like 'uniqueSuffix' for custom logic, ensuring SEO-friendly URLs without collisions.
Supports multiple slug fields per model, custom separators, language-specific rulesets (e.g., Finnish), and event hooks ('slugging', 'slugged'), allowing fine-tuned control as detailed in the Configuration section.
Includes SluggableScopeHelpers trait for easy model retrieval by slug, such as Post::findBySlug('my-post'), simplifying route model binding and database queries without extra boilerplate.
The default 'saving' event prevents using primary keys in slug sources, and switching to 'saved' requires extra database queries—a trade-off admitted in the README that can impact performance and validation.
Explicitly states that support for Laravel Lumen has been discontinued, limiting adoption in micro-framework projects and forcing users to seek alternatives or fork the package.
Requires users to manually add nullable slug columns via migrations, unlike some packages that auto-handle schema changes, adding an extra step in setup and maintenance.