codinglabsau/laravel-sluggable

Generate slugs when saving Eloquent models

v1.1.1 2024-03-11 04:23 UTC

This package is auto-updated.

Last update: 2024-05-11 04:44:34 UTC


README

Build Status Latest Stable Version Total Downloads License

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.