duyduc-nguyen/laravel-sluggable-trait

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

Installs: 35

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/duyduc-nguyen/laravel-sluggable-trait

0.1.2 2015-10-25 04:06 UTC

This package is not auto-updated.

Last update: 2025-10-12 00:36:25 UTC


README

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.