Gurzhii / laravel-sluggable-trait by Gurzhii
forked from martinbean/laravel-sluggable-trait

A trait you can apply to Eloquent models to have slugs automatically generated on save.
268
0
1
Package Data
Maintainer Username: Gurzhii
Maintainer Contact: martin@martinbean.co.uk (Martin Bean)
Package Create Date: 2016-04-22
Package Last Update: 2016-05-11
Language: PHP
License: MIT
Last Refreshed: 2024-11-12 15:02:41
Package Statistics
Total Downloads: 268
Monthly Downloads: 1
Daily Downloads: 0
Total Stars: 0
Total Watchers: 1
Total Forks: 0
Total Open Issues: 0

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.