Skip to content

Releases: LaraPire/laravel-slugable

v1.1.2

30 Oct 00:17

Choose a tag to compare

Changes:

  • fix: add id parameter to resource routes

v1.1.1

23 Jun 02:14
e10634d

Choose a tag to compare

Laravel Slugable v2.0 - Modern Multi-Language Slug Generator

The new version of Laravel Slugable is here! v2.0 is a powerful and modern trait for generating SEO-friendly slugs in Laravel, with major improvements and full backward compatibility.


New Features & Improvements

Multi-Language Support

  • Full support for Persian (fa), Arabic (ar), and English (en)
  • Automatic conversion of Persian/Arabic digits to English
  • Language-specific character cleaning and preservation

Enhanced Configuration

  • Customizable separator (-, _, etc.)
  • Configurable maximum slug length
  • Force update option to regenerate slugs
  • Unique slug enforcement with automatic counters

Static Slug Generation

  • New generateSlugFrom() method
  • Allows slug creation without a model instance (ideal for seeders, migrations, etc.)

Performance Optimizations

  • Constant-based patterns for faster processing
  • More efficient uniqueness checks
  • Full support for soft-deleted models

Modern Codebase

  • Uses PHP 8+ features (typed properties, match, arrow functions)
  • Cleaner structure with focused methods
  • Type-safe with strict comparisons

Installation

composer require rayiumir/laravel-slugable

Why Upgrade?

  • Greater control over slug generation
  • Improved performance
  • Out-of-the-box multi-language support
  • Clean, modern PHP 8+ codebase

v1.1.0

08 Jun 11:10
ff9f009

Choose a tag to compare

Changes :

What's New

1. Multi-language Support

  • Added support for fa (Persian), ar (Arabic), and en (English).
  • Properly handles zero-width non-joiners, Tatweel, and script-specific characters.
  • Custom regex patterns for each language for accurate slug cleanup.

2. Customization Options

  • Set custom slug source and destination fields.
  • Specify custom separator (default: -).
  • Set maximum length for slugs.
  • Force slug regeneration on every save.
  • Enable/disable uniqueness check for slugs.

3. Improved Uniqueness Enforcement

  • Ensures uniqueness using incremental suffixes (-2, -3, etc.).
  • Skips current model record in uniqueness check.
  • Supports models using SoftDeletes with optional withTrashed() check.

4. Better Code Structure

  • Separated logic into clear, testable methods:
    • generateSlug()
    • convertToSlug()
    • convertNumbers()
    • makeSlugUnique()
    • slugExists()
    • usesSoftDeletes()
    • processLanguageSpecificChars()
    • getCharacterPatternForLanguage()
    • cleanUpSeparators()
  • Uses type hinting and default values.
  • More readable and maintainable.

5. Compatibility with Route Model Binding

  • getRouteKeyName() dynamically returns the slug field used for routing.

Example Usage

class Post extends Model
{
    use HasSlugable;

    // Optional configurations
    protected $slugSourceField = 'title';
    protected $slugDestinationField = 'slug';
    protected $slugSeparator = '-';
    protected $slugLanguage = 'fa'; // Supports 'fa', 'ar', 'en'
    protected $slugMaxLength = 100;
    protected $slugForceUpdate = false;
    protected $slugShouldBeUnique = true;
}

Thank you @itashia

v1.0.4

07 Apr 14:40

Choose a tag to compare

Changes:

  • Remove Finglish and Arabtini translations for Slug
  • Fixed Comments HasSlugable

v1.0.3

06 Apr 20:33

Choose a tag to compare

Changes:

  • Update README.md - Added Facade - Fixed Slugable
  • Fixed Slugable

v1.0.2

06 Apr 14:50

Choose a tag to compare

Changes:

  • Fixed Slugable

v1.0.1

06 Apr 01:02

Choose a tag to compare

Changes :

  • Changes function HasSlug
  • Added Tests
  • Supported From Persian and Arabic to translate slug

v1.0.0

05 Apr 22:26

Choose a tag to compare

Changes :

  • Added HasSlug trait for Eloquent Models
  • Added Composer.json
  • Added SlugServiceProvider
  • Fixed namespace and Added return type