Download the PHP package martinbean/laravel-sluggable-trait without Composer
On this page you can find all versions of the php package martinbean/laravel-sluggable-trait. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download martinbean/laravel-sluggable-trait
More information about martinbean/laravel-sluggable-trait
Files in martinbean/laravel-sluggable-trait
Package laravel-sluggable-trait
Short Description A trait you can apply to Eloquent models to have slugs automatically generated on save.
License MIT
Informations about the package laravel-sluggable-trait
Laravel Sluggable Trait
A trait you can apply to Eloquent models to have slugs automatically generated on save.
Installation
Usage
By default, the trait assumes your database has two columns: name
and slug
.
If you need to change these, you can override the getter methods:
Note: The visibility of these methods changed from public
to protected
in version 0.4.0 of this package.
The getSlugColumnName()
method should return the name of the column you want
to store slugs in your database table.
The getSluggableString()
should return a string you want to create a slug
from. This is exposed as a method and not a property or constantly as you may
want to create a slug from the value of one than one column. For example:
Configuration
By default, the package will use dashes as word separators in slugs, i.e. this-is-your-slug
. The separator character can be changed by publishing the package’s configuration file and specifying your own separator character.
You can then change the separator value to something like an underscore in the published config/sluggable.php file:
Note: Changing the slug separator won’t change any existing slugs in your database. You’ll need to update those manually if you change the separator.
License
Licensed under the MIT Licence.