codinglabsau / laravel-sluggable
Generate slugs when saving Eloquent models
Installs: 7 607
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^8.1
- illuminate/support: ^10.0|^11.0
Requires (Dev)
- codinglabsau/php-styles: dev-main
README
A super simple, opinionated trait to add slugs to models in Laravel.
Installation
Via Composer
$ composer require codinglabsau/laravel-sluggable
Usage
Add name
and slug
columns to your model
This package watches for changes on the name
attribute, and automatically slugifies the slug column.
Add the trait
Add the Sluggable
trait to your user model:
use Codinglabs\Sluggable\Sluggable; use Illuminate\Database\Eloquent\Model; class Product extends Model { use Sluggable; }
Contributing
Feel free to create a PR with tests!
Security
If you discover any security related issues, create an issue on GitHub.
Credits
License
MIT. Please see the license file for more information.
About Coding Labs
Coding Labs is a web app development agency based on the Gold Coast, Australia. See our open source projects on our website.