Looking to hire Laravel developers? Try LaraJobs

laravel-sluggable-trait maintained by duyduc-nguyen

Description
Create unique slugs for your Eloquent models in Laravel. Support Cache
Last update
2015/10/25 05:06 (dev-master)
License
Links
Downloads
35
Tags

Comments
comments powered by Disqus

Laravel Sluggable Trait

Create unique slugs for your Eloquent models in Laravel. Support Cache

Install

$ composer require duyduc-nguyen/laravel-sluggable-trait

Usage

<?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;

License

Licensed under the MIT Licence.