cserobiul / slug
Simple and Easy Laravel Unicode Supported Unique Slug Generator Package
Installs: 64
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/cserobiul/slug
Requires
- php: >=7.4
This package is auto-updated.
Last update: 2025-10-14 21:22:10 UTC
README
Very Simple and Easy Package
Installation
composer require cserobiul/slug
Configuration
No Configuration Need
Use from Controller
Import Slug class
use Cserobiul\Slug\Slug;
Publish configuration
php artisan vendor:publish cserobiul/slug
Example #01- Blog unique slug from 'Blog Title'
Suppose, we already have blogs table and added an slug column which is unique. Now, if we passed title and generate unique slug from that.
// 1st time create slug Slug::make('blogs', 'Blog Title', 'slug'); // Output: blog-title // 2nd time create slug Slug::make('blogs', 'Blog Title', 'slug'); // Output: blog-title-1 // 3rd time create slug Slug::make('blogs', 'Blog Title', 'slug'); // Output: blog-title-2 // 4th time create slug Slug::make('blogs', 'Blog Title', 'slug'); // Output: blog-title-3
Example #02- Blog 'Unicode Title' to unique slug
// 1st time create slug Slug::make('blogs', 'প্রেমের নাম বেদনা', 'slug'); // Output: প্রেমের-নাম-বেদনা // 2nd time create slug Slug::make('blogs', 'প্রেমের নাম বেদনা', 'slug'); // Output: প্রেমের-নাম-বেদনা-1 // 3rd time create slug Slug::make('blogs', 'প্রেমের নাম বেদনা', 'slug'); // Output: প্রেমের-নাম-বেদনা-2 // 4th time create slug Slug::make('blogs', 'প্রেমের নাম বেদনা', 'slug'); // Output: প্রেমের-নাম-বেদনা-3
Example #03 - Pass custom separator for Customer Table
Suppose separator is _ underscore.
// 1st time create customer username. UniqueSlug::make('customers', 'jony', 'username', '_'); // Output: jony // 2nd time create customer username. UniqueSlug::make('customers', 'jony', 'username', '_'); // Output: jony_1 // 3rd time create customer username. UniqueSlug::make('customers', 'jony', 'username', '_'); // Output: jony_2 // 4th time create customer username. UniqueSlug::make('customers', 'jony', 'username', '_'); // Output: jony_3
Contribution
Anyone can create any Pull request.