| Package Data | |
|---|---|
| Maintainer Username: | duyduc-nguyen |
| Maintainer Contact: | duyduc.uit@gmail.com (Nguyen Chi Duy Duc) |
| Package Create Date: | 2015-10-19 |
| Package Last Update: | 2015-10-25 |
| Language: | PHP |
| License: | MIT |
| Last Refreshed: | 2025-10-23 03:00:20 |
| Package Statistics | |
|---|---|
| Total Downloads: | 35 |
| Monthly Downloads: | 0 |
| Daily Downloads: | 0 |
| Total Stars: | 3 |
| Total Watchers: | 1 |
| Total Forks: | 0 |
| Total Open Issues: | 0 |
Create unique slugs for your Eloquent models in Laravel. Support Cache
$ composer require duyduc-nguyen/laravel-sluggable-trait
<?php namespace App;
use Illuminate\Database\Eloquent\Model;
use DuyDucNguyen\Database\Traits\SluggableTrait;
class Item extends Model {
use SluggableTrait;
}
First, you need to indicate sluggable column and slug column of your model via class constants:
<?php namespace App;
use Illuminate\Database\Eloquent\Model;
use DuyDucNguyen\Database\Traits\SluggableTrait;
class Item extends Model {
use Sluggable;
const SLUGGABLE_COLUMN = 'title';
const SLUG = 'slug';
}
If you need to improve your query for searching slug, you can enable Laravel Cache for caching slug via
const ENABLE_SLUG_CACHE = true;
Licensed under the MIT Licence.