Looking to hire Laravel developers? Try LaraJobs

laravel-sluggable-trait maintained by gurzhii

Description
A trait you can apply to Eloquent models to have slugs automatically generated on save.
Last update
2016/05/11 10:06 (dev-master)
License
Links
Downloads
270
Tags

Comments
comments powered by Disqus

Laravel Sluggable Trait

A trait you can apply to Eloquent models to have slugs automatically generated on save.

Installation

$ composer require gurzhii/laravel-sluggable-trait

Usage

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

}

License

Licensed under the MIT Licence.