ifranksmith/laravel-sluggable is a Laravel package for laravel slug maker trait.
It currently has 2 GitHub stars and 315 downloads on Packagist.
Install it with composer require ifranksmith/laravel-sluggable.
Discover more Laravel packages by ifranksmith
or browse all Laravel packages to compare alternatives.
Last updated
Allows Laravel Eloquent models to implement a 'sluggable' feature.
$ composer require ifranksmith/laravel-sluggable
config/app.php by adding an entry for the service provider.'providers' => [
// ...
IFrankSmith\Sluggable\SluggableServiceProvider
];
Your models should import the Traits/Sluggable.php trait and use it.
(see an example below):
use IFrankSmith\Sluggable\Traits\Sluggable;
class Posts extends Model
{
use Sluggable;
}
By default, this package will generate slug from the 'name' property of the mmodel and save it to the 'slug' property of the model.
However, if your model does not use those properties, you need to create a method on your model that returns the respective column and source. For example, if you want to make slug from 'title' to 'title_slug' property, you need to use it as shown below
use IFrankSmith\Sluggable\Traits\Sluggable;
class Posts extends Model
{
use Sluggable;
public function sluggable()
{
return [
"column" => "title_slug",
"source" => "title",
];
}
}
That's it ... your model is now "sluggable"!