Package Data | |
---|---|
Maintainer Username: | Gurzhii |
Maintainer Contact: | martin@martinbean.co.uk (Martin Bean) |
Package Create Date: | 2016-04-22 |
Package Last Update: | 2016-05-11 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-12 15:02:41 |
Package Statistics | |
---|---|
Total Downloads: | 268 |
Monthly Downloads: | 1 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 1 |
Total Forks: | 0 |
Total Open Issues: | 0 |
A trait you can apply to Eloquent models to have slugs automatically generated on save.
$ composer require gurzhii/laravel-sluggable-trait
<?php namespace App;
use Illuminate\Database\Eloquent\Model;
use MartinBean\Database\Eloquent\Sluggable;
class Item extends Model {
use Sluggable;
}
By default, the trait assumes your database has two columns: name
and slug
.
If you need to change these, you can do so via class constants:
<?php namespace App;
use Illuminate\Database\Eloquent\Model;
use MartinBean\Database\Eloquent\Sluggable;
class Item extends Model {
use Sluggable;
const DISPLAY_NAME = 'headline';
const SLUG = 'seo_url';
}
Licensed under the MIT Licence.