{"id":19052423,"url":"https://github.com/amdad121/unique-slug-laravel","last_synced_at":"2026-05-13T20:31:37.146Z","repository":{"id":211747472,"uuid":"729859997","full_name":"amdad121/unique-slug-laravel","owner":"amdad121","description":"Unique slug generator for Laravel","archived":false,"fork":false,"pushed_at":"2026-02-02T09:05:39.000Z","size":40,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-13T12:16:11.352Z","etag":null,"topics":["generator","laravel","slug","unique"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amdad121.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"amdad121"}},"created_at":"2023-12-10T15:25:22.000Z","updated_at":"2026-02-02T09:05:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"8243ba07-0772-455b-bf3e-85619d8c787f","html_url":"https://github.com/amdad121/unique-slug-laravel","commit_stats":null,"previous_names":["amdad121/unique-slug-laravel"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/amdad121/unique-slug-laravel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amdad121%2Funique-slug-laravel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amdad121%2Funique-slug-laravel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amdad121%2Funique-slug-laravel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amdad121%2Funique-slug-laravel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amdad121","download_url":"https://codeload.github.com/amdad121/unique-slug-laravel/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amdad121%2Funique-slug-laravel/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32999165,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"ssl_error","status_checked_at":"2026-05-13T13:14:51.610Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["generator","laravel","slug","unique"],"created_at":"2024-11-08T23:26:22.262Z","updated_at":"2026-05-13T20:31:37.141Z","avatar_url":"https://github.com/amdad121.png","language":"PHP","funding_links":["https://github.com/sponsors/amdad121"],"categories":[],"sub_categories":[],"readme":"# Unique slug generator for Laravel\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/amdadulhaq/unique-slug-laravel.svg?style=flat-square)](https://packagist.org/packages/amdadulhaq/unique-slug-laravel)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/amdad121/unique-slug-laravel/run-tests.yml?branch=main\u0026label=tests\u0026style=flat-square)](https://github.com/amdad121/unique-slug-laravel/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/amdad121/unique-slug-laravel/fix-php-code-style-issues.yml?branch=main\u0026label=code%20style\u0026style=flat-square)](https://github.com/amdad121/unique-slug-laravel/actions?query=workflow%3A\"Fix+PHP+code+style+issues\"+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/amdadulhaq/unique-slug-laravel.svg?style=flat-square)](https://packagist.org/packages/amdadulhaq/unique-slug-laravel)\n\nA powerful and flexible unique slug generator package for Laravel with advanced features.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require amdadulhaq/unique-slug-laravel\n```\n\nPublish the configuration file:\n\n```bash\nphp artisan vendor:publish --tag=unique-slug-config\n```\n\n## Usage\n\n### Basic Usage\n\n```php\nnamespace App\\Models;\n\nuse AmdadulHaq\\UniqueSlug\\HasSlug;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Article extends Model\n{\n    use HasSlug;\n\n    protected $fillable = ['name', 'slug'];\n}\n```\n\n```php\nArticle::create(['name' =\u003e 'Hello World']);\n// Generates slug: hello-world\n\nArticle::create(['name' =\u003e 'Hello World']);\n// Generates slug: hello-world-1\n```\n\n### Configuration Options\n\n#### Custom Source and Slug Fields\n\n```php\nclass Article extends Model\n{\n    use HasSlug;\n\n    public function getSlugSourceAttribute(): string\n    {\n        return 'title'; // Generate slug from title field\n    }\n\n    public function getSlugNameAttribute(): string\n    {\n        return 'slug'; // Store slug in slug field\n    }\n\n    public function getSlugSeparator(): string\n    {\n        return '_'; // Use underscore separator\n    }\n}\n```\n\n#### Using Configuration File\n\n```php\n// config/slug.php\nreturn [\n    'update_on_update' =\u003e env('SLUG_UPDATE_ON_UPDATE', false),\n    'case' =\u003e env('SLUG_CASE', 'lower'),\n    'max_length' =\u003e env('SLUG_MAX_LENGTH', 255),\n    'reserved_slugs' =\u003e ['admin', 'dashboard', 'api'],\n    'suffix_separator' =\u003e env('SLUG_SUFFIX_SEPARATOR', '-'),\n    'skip_on_empty' =\u003e env('SLUG_SKIP_ON_EMPTY', false),\n    'include_soft_deleted' =\u003e env('SLUG_INCLUDE_SOFT_DELETED', false),\n];\n```\n\n### Advanced Features\n\n#### Custom Slug Generation\n\n```php\nclass Article extends Model\n{\n    use HasSlug;\n\n    protected function generateCustomSlug(string $source): string\n    {\n        return 'article-'.strtolower($source);\n    }\n}\n```\n\n#### Conditional Slug Generation\n\n```php\nclass Article extends Model\n{\n    use HasSlug;\n\n    public function shouldSkipSlug(): bool\n    {\n        return $this-\u003epublished === false;\n    }\n}\n```\n\n#### Case Transformation\n\nAvailable cases: `lower`, `upper`, `title`, `camel`, `snake`\n\n```php\nconfig(['slug.case' =\u003e 'upper']);\nArticle::create(['name' =\u003e 'Hello World']);\n// Generates slug: HELLO-WORLD\n```\n\n#### Maximum Length\n\n```php\nconfig(['slug.max_length' =\u003e 50]);\nArticle::create(['name' =\u003e 'Very Long Title That Should Be Truncated']);\n// Truncates slug to 50 characters\n```\n\n#### Reserved Slugs\n\n```php\nconfig(['slug.reserved_slugs' =\u003e ['admin', 'dashboard']]);\nArticle::create(['name' =\u003e 'admin']);\n// Generates slug: admin-1\n```\n\n### Query Scopes\n\n```php\nArticle::whereSlug('hello-world')-\u003efirst();\nArticle::orWhereSlug('another-slug')-\u003eget();\nArticle::whereSlugLike('hello')-\u003eget();\n```\n\n### Soft Delete Support\n\n```php\nclass Article extends Model\n{\n    use HasSlug;\n    use \\Illuminate\\Database\\Eloquent\\SoftDeletes;\n}\n\n// Include soft deleted records in uniqueness check\nconfig(['slug.include_soft_deleted' =\u003e true]);\n```\n\n## Environment Variables\n\n```env\nSLUG_UPDATE_ON_UPDATE=false\nSLUG_CASE=lower\nSLUG_MAX_LENGTH=255\nSLUG_RESERVED_SLUGS=admin,dashboard,api\nSLUG_SUFFIX_SEPARATOR=-\nSLUG_SKIP_ON_EMPTY=false\nSLUG_INCLUDE_SOFT_DELETED=false\n```\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n-   [Amdadul Haq](https://github.com/amdad121)\n-   [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famdad121%2Funique-slug-laravel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famdad121%2Funique-slug-laravel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famdad121%2Funique-slug-laravel/lists"}