library eloquent-sluggable
Sluggable Eloquent model class
mr-timofey/eloquent-sluggable
Sluggable Eloquent model class
- Sunday, April 15, 2018
- by mrTimofey
- Repository
- 1 Watchers
- 2 Stars
- 768 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 6 Versions
- 32 % Grown
Slugs for Eloquent models., (*1)
Features
-
findBySlug, findBySlugOrFail, findByAny, findByAnyOrFail
- Automatic slug generation on create (if not set manually) by transliterating source attribute
- Automatic unique constraint check after any slug modification on each saving
(slug will be appended with -1/2/3/... until becomes unique)
- Both slug or ID route resolving (assuming ID field is integer)
- Almost anything can be customized by method overriding or class fields
Requirements
Install
composer require mr-timofey/eloquent-sluggable
Usage
Just use MrTimofey\EloquentSluggable\Sluggable trait by any of your model classes. Define fields if needed:, (*2)
class MyModel extends \Illuminate\Database\Eloquent\Model {
use \MrTimofey\EloquentSluggable\Sluggable;
/**
* @var string attribute name that used as a source for transliteration
*/
protected static $slugSource = 'name';
/**
* @var string attribute name containing a slug itself
*/
protected static $slugField = 'slug';
/**
* @var bool slug can be null
*/
protected static $slugNullable = false;
}
See trait source code if you need more customizations., (*3)
dev-master
9999999-dev
Sluggable Eloquent model class
Sources
Download
MIT
The Requires
by
Timofey
0.1.1
0.1.1.0
Sluggable Eloquent model class
Sources
Download
MIT
The Requires
by
Timofey
0.1.0
0.1.0.0
Sluggable Eloquent model class
Sources
Download
MIT
The Requires
by
Timofey
0.0.3
0.0.3.0
Sluggable Eloquent model class
Sources
Download
MIT
The Requires
by
Timofey
0.0.2
0.0.2.0
Sluggable Eloquent model class
Sources
Download
MIT
The Requires
by
Timofey
0.0.1
0.0.1.0
Sluggable Eloquent model class
Sources
Download
MIT
The Requires
by
Timofey