| Package Data | |
|---|---|
| Maintainer Username: | kduma | 
| Maintainer Contact: | oss@krystian.duma.sh (Krystian Duma) | 
| Package Create Date: | 2015-01-31 | 
| Package Last Update: | 2025-09-04 | 
| Home Page: | https://opensource.duma.sh/libraries/php/eloquent-sluggable | 
| Language: | PHP | 
| License: | MIT | 
| Last Refreshed: | 2025-10-27 03:21:28 | 
| Package Statistics | |
|---|---|
| Total Downloads: | 789 | 
| Monthly Downloads: | 0 | 
| Daily Downloads: | 0 | 
| Total Stars: | 2 | 
| Total Watchers: | 1 | 
| Total Forks: | 0 | 
| Total Open Issues: | 0 | 
Eases using and generating slugs Laravel Eloquent models.
Add the package to the require section of your composer.json and run composer update
"kduma/eloquent-sluggable": "^1.1"
Inside your model (not on top of file) add following lines:
use \KDuma\Eloquent\Slugabble;
Optionally you can add also SluggableString function which will return string from which slug will be made (default it uses title field):
protected function SluggableString(){
    return $this->year.' '.$this->title;
}  
In database create slug string field. If you use migrations, you can use following snippet:
$table->string('slug')->unique();
By default it generates slug on first save.
$model->newSlug() - Generate new slug. (Remember to save it by yourself)Model::whereSlug($slug)->first() - Find by slug. (whereSlug is query scope)A special thanks to Eric L. Barnes, an original code creator that this package is based on.
View this package on Packagist.org: kduma/eloquent-sluggable