{"id":36398500,"url":"https://github.com/paxha/laravel-sluggable","last_synced_at":"2026-01-11T16:01:35.170Z","repository":{"id":55680077,"uuid":"230079302","full_name":"paxha/laravel-sluggable","owner":"paxha","description":"This package provides an event that will generate a unique slug when saving or creating any Eloquent model.","archived":false,"fork":false,"pushed_at":"2020-12-17T16:17:13.000Z","size":29,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-01T14:15:01.944Z","etag":null,"topics":["laravel","laravel-package","laravel-sluggable","slug","sluggable"],"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/paxha.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-25T09:36:44.000Z","updated_at":"2020-12-17T16:16:14.000Z","dependencies_parsed_at":"2022-08-15T06:20:39.524Z","dependency_job_id":null,"html_url":"https://github.com/paxha/laravel-sluggable","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/paxha/laravel-sluggable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paxha%2Flaravel-sluggable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paxha%2Flaravel-sluggable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paxha%2Flaravel-sluggable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paxha%2Flaravel-sluggable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paxha","download_url":"https://codeload.github.com/paxha/laravel-sluggable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paxha%2Flaravel-sluggable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28312078,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T14:58:17.114Z","status":"ssl_error","status_checked_at":"2026-01-11T14:55:53.580Z","response_time":60,"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":["laravel","laravel-package","laravel-sluggable","slug","sluggable"],"created_at":"2026-01-11T16:00:38.853Z","updated_at":"2026-01-11T16:01:35.154Z","avatar_url":"https://github.com/paxha.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003ca href=\"https://travis-ci.org/paxha/laravel-sluggable\"\u003e\u003cimg src=\"https://img.shields.io/travis/paxha/laravel-sluggable/master.svg?style=flat-square\" alt=\"Build Status\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.styleci.io/repos/230079302\"\u003e\u003cimg src=\"https://github.styleci.io/repos/230079302/shield?branch=master\" alt=\"StyleCI\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/paxha/laravel-sluggable\"\u003e\u003cimg src=\"https://poser.pugx.org/paxha/laravel-sluggable/d/total.svg?format=flat-square\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/paxha/laravel-sluggable\"\u003e\u003cimg src=\"https://poser.pugx.org/paxha/laravel-sluggable/v/stable.svg?format=flat-square\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/paxha/laravel-sluggable\"\u003e\u003cimg src=\"https://poser.pugx.org/paxha/laravel-sluggable/license.svg?format=flat-square\" alt=\"License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# Laravel Slug Generator\n\n## Introduction\n\nThis package provides an event that will generate a unique slug when saving or creating any Eloquent model.\n\n## Installation\n\n    composer require paxha/laravel-sluggable\n\n## Usage\n\n-   [Getting Started](#getting-started)\n-   [Examples](#examples)\n\n### Getting Started\n\nConsider the following table schema for hierarchical data:\n\n```php\nSchema::create('users', function (Blueprint $table) {\n    $table-\u003eincrements('id');\n    $table-\u003estring('name');\n    $table-\u003estring('slug')-\u003eunique();\n});\n```\n\nUse the `Sluggable` trait in your model to work with slug:\n\n```php\nclass User extends Model\n{\n    use \\Sluggable\\Traits\\Sluggable;\n}\n```\n\nBy default, the trait expects three things \n\n1.  slugFrom(): array (optional) if you using `name` column\n2.  slugSaveTo(): string (optional) if you using `slug` column\n3.  separator(): string (optional) default `-`\n\nYou can overriding it as well `slugFrom()`, `slugSaveTo()` and `separator()`:\n\n```php\nclass User extends Model\n{\n    use \\Sluggable\\Traits\\Sluggable;\n\n    public static function slugFrom()\n    {\n        return ['name']; // or return ['first_name', 'last_name'];\n    }\n \n    public static function slugSaveTo()\n    {\n        return 'slug'; // or return ['user_slug'];\n    }\n \n    public static function separator()\n    {\n        return '-'; // or return '_';\n    }\n}\n```\n\n### Examples\n\n#### Example A\n\n##### Database\n\n```php\nSchema::create('users', function (Blueprint $table) {\n    $table-\u003eincrements('id');\n    $table-\u003estring('first_name');\n    $table-\u003estring('last_name');\n    $table-\u003estring('slug')-\u003eunique();\n});\n```\n\n##### Model\n\n```php\nclass User extends Model\n{\n    use \\Sluggable\\Traits\\Sluggable;\n\n    protected $fillable = [\n        'first_name', 'last_name',\n    ];\n\n    public static function slugFrom()\n    {\n        return ['first_name', 'last_name'];\n    }\n}\n```\n\n##### Create User\n\n```php\nUser::create([\n    'first_name' =\u003e 'John',\n    'last_name' =\u003e 'Doe'\n]);\n\n// or\n\n$user = new User();\n$user-\u003efirst_name = 'John';\n$user-\u003elast_name = 'Doe';\n$user-\u003esave();\n```\n\n##### Output\n\n```json5\n{\n    'first_name': 'John',\n    'last_name': 'Doe',\n    'slug': 'john-doe',\n}\n```\n\n#### Example B\n\n##### Table\n\n```php\nSchema::create('users', function (Blueprint $table) {\n    $table-\u003eincrements('id');\n    $table-\u003estring('name');\n    $table-\u003estring('user_slug')-\u003eunique();\n});\n```\n\n##### Model\n\n```php\nclass User extends Model\n{\n    use \\Sluggable\\Traits\\Sluggable;\n    \n    protected $fillable = [\n        'name',\n    ];\n\n    public static function slugSaveTo()\n    {\n        return ['user_slug'];\n    }\n\n    public static function separator()\n    {\n        return '_';\n    }\n}\n```\n\n##### Create User\n\n```php\nUser::create([\n    'name' =\u003e 'John Doe'\n]);\n\n// or\n\n$user = new User();\n$user-\u003ename = 'John Doe';\n$user-\u003esave();\n```\n\n##### Output\n\n```json5\n{\n    'name': 'John Doe',\n    'user_slug': 'john_doe',\n}\n```\n\n## License\n\nThis is open-sourced laravel library licensed under the [MIT license](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaxha%2Flaravel-sluggable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaxha%2Flaravel-sluggable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaxha%2Flaravel-sluggable/lists"}