Download the PHP package aesircloud/sluggable without Composer
On this page you can find all versions of the php package aesircloud/sluggable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download aesircloud/sluggable
More information about aesircloud/sluggable
Files in aesircloud/sluggable
Package sluggable
Short Description A Laravel package to automatically generate slugs for models
License MIT
Homepage https://github.com/AesirCloud/Sluggable
Informations about the package sluggable
Generate unique slugs when creating or updating Eloquent models
sluggable
is a Laravel package that generates unique slugs for Eloquent models. It can be used to automatically generate slugs when creating or updating models, with flexible options controlled by both a config file and model-level properties.
Installation
You can install the package via Composer:
Publish the configuration file
Usage
Add the Sluggable
trait to your model:
2. Migrate the Slug Column
Ensure your table has a suitable column for the slug:
3. Configuration Options
Open config/sluggable.php
to see the available options. You can override any of these in your model by defining the corresponding property.
- source: The default field the slug is generated from if you don’t set $slugSource in the model.
- column: The column to store the slug.
- update: Set true to automatically regenerate a slug when the source field changes on update.
- max_length: Truncates the slug (plus space for numeric suffixes) to this length if specified.
- scopes: Array of columns to scope uniqueness (e.g., if you only want unique slugs per category_id).
4. Route Model Binding (Optional)
If you want to use the slug in your routes, you can override getRouteKeyName() in your model:
Then reference it in your routes:
Changelog
Please see CHANGELOG for more information what has changed recently.
Security
If you've found a bug regarding security please mail [email protected] instead of using the issue tracker.
LICENSE
The MIT License (MIT). Please see License file for more information.
All versions of sluggable with dependencies
illuminate/database Version ^11.0|^12.0
illuminate/support Version ^11.0|^12.0