Download the PHP package rayiumir/laravel-slugable without Composer
On this page you can find all versions of the php package rayiumir/laravel-slugable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rayiumir/laravel-slugable
More information about rayiumir/laravel-slugable
Files in rayiumir/laravel-slugable
Package laravel-slugable
Short Description Minimal auto slug trait for Laravel Eloquent models.
License MIT
Informations about the package laravel-slugable
Laravel Slugable
Laravel Slugable is a lightweight Laravel trait that automatically generates slugs from model fields like title, name, or any custom source — and stores it in a customizable destination field such as slug, etc.
Perfect for blogs, e-commerce, CMS, or any app that needs clean, readable, SEO-friendly URLs with multi-language support.
Features
- Auto-generate slug on model creation
- Optional re-generation on model update
- Customizable source and destination fields
- Multi-language support (Persian, Arabic, English)
- Automatic conversion of non-English numbers
- Special character cleaning for each language
- Unique slug enforcement with counter
- Max length enforcement
- No external dependencies
- Static helper method for non-model usage
- Thread-safe implementation
- Type-safe operations
Installation
Install Package:
After Publish Files:
Basic Usage
Calling HasSlugable in Models Post.php:
Provided that the title and slug fields are in the database.
Advanced Configuration
Custom Field Names
Language Support
Other Options
Static Usage
You can generate slugs without a model instance:
Example Workflow
Language-Specific Handling
The trait automatically handles:
- Persian/Arabic numbers conversion
- ZWNJ (Zero-width non-joiner) removal for Persian
- Tatweel removal for Arabic/Persian
- Language-specific character preservation
Best Practices
-
Add index to your slug column for better performance:
-
For large tables, consider adding the slug generation in a migration:
- Use the static method when generating slugs in migrations:
Performance Notes
- The trait uses efficient string operations
- Language patterns are defined as constants for better performance
- Slug uniqueness check is optimized to exclude current model
- Works with soft-deleted models