[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-2057":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":15,"stars30d":14,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":17,"rankGlobal":10,"rankLanguage":10,"license":18,"archived":19,"fork":19,"defaultBranch":20,"hasWiki":19,"hasPages":19,"topics":21,"createdAt":10,"pushedAt":10,"updatedAt":26,"readmeContent":27,"aiSummary":28,"trendingCount":16,"starSnapshotCount":16,"syncStatus":14,"lastSyncTime":29,"discoverSource":30},2057,"laravel-sluggable","nunomaduro\u002Flaravel-sluggable","nunomaduro","Laravel Sluggable is my opinionated take on automatic slug generation for Eloquent models","https:\u002F\u002Fyoutube.com\u002F@nunomaduro?sub_confirmation=1",null,"PHP",138,4,2,1,0,2.1,"MIT License",false,"1.x",[22,23,24,25],"eloquent","laravel","models","slugs","2026-06-12 02:00:36","\u003Cp align=\"center\">\n    \u003Cimg src=\"https:\u002F\u002Fraw.githubusercontent.com\u002Fnunomaduro\u002Flaravel-sluggable\u002F1.x\u002Fdocs\u002Flogo.png\" alt=\"Laravel Sluggable code example\" height=\"300\">\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n    \u003Cp align=\"center\">\n        \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fnunomaduro\u002Flaravel-sluggable\u002Factions\">\u003Cimg alt=\"GitHub Workflow Status (master)\" src=\"https:\u002F\u002Fgithub.com\u002Fnunomaduro\u002Flaravel-sluggable\u002Factions\u002Fworkflows\u002Ftests.yml\u002Fbadge.svg\">\u003C\u002Fa>\n        \u003Ca href=\"https:\u002F\u002Fpackagist.org\u002Fpackages\u002Fnunomaduro\u002Flaravel-sluggable\">\u003Cimg alt=\"Total Downloads\" src=\"https:\u002F\u002Fimg.shields.io\u002Fpackagist\u002Fdt\u002Fnunomaduro\u002Flaravel-sluggable\">\u003C\u002Fa>\n        \u003Ca href=\"https:\u002F\u002Fpackagist.org\u002Fpackages\u002Fnunomaduro\u002Flaravel-sluggable\">\u003Cimg alt=\"Latest Version\" src=\"https:\u002F\u002Fimg.shields.io\u002Fpackagist\u002Fv\u002Fnunomaduro\u002Flaravel-sluggable\">\u003C\u002Fa>\n        \u003Ca href=\"https:\u002F\u002Fpackagist.org\u002Fpackages\u002Fnunomaduro\u002Flaravel-sluggable\">\u003Cimg alt=\"License\" src=\"https:\u002F\u002Fimg.shields.io\u002Fpackagist\u002Fl\u002Fnunomaduro\u002Flaravel-sluggable\">\u003C\u002Fa>\n        \u003Ca href=\"https:\u002F\u002Fyoutube.com\u002F@nunomaduro?sub_confirmation=1\">\u003Cimg alt=\"YouTube Channel Subscribers\" src=\"https:\u002F\u002Fimg.shields.io\u002Fyoutube\u002Fchannel\u002Fsubscribers\u002FUCO_hYZF2gb_CyG5sA7ArlGg?style=flat&label=youtube&color=brightgreen\">\u003C\u002Fa>\n        \u003Ca href=\"https:\u002F\u002Fpackagist.org\u002Fpackages\u002Fnunomaduro\u002Flaravel-sluggable\">\u003Cimg alt=\"Laravel Compatibility\" src=\"https:\u002F\u002Fbadge.laravel.cloud\u002Fbadge\u002Fnunomaduro\u002Flaravel-sluggable\">\u003C\u002Fa>\n    \u003C\u002Fp>\n\u003C\u002Fp>\n\n------\n\n**Laravel Sluggable** is my opinionated take on **automatic slug generation for Eloquent models** — the exact pattern I've reached for across projects like **Laravel Cloud**, now packaged up. A single `#[Sluggable]` attribute on the model is all you need. No trait, no base class, no extra wiring.\n\nIt handles **all of the weirdest edge cases** you can think about; slugs collisions, Unicode and CJK transliteration, domain-aware dot preservation, scoped uniqueness (per-tenant, per-locale), multi-column sources, soft-deleted record collisions, and more.\n\n> **Requires [PHP 8.5+](https:\u002F\u002Fphp.net\u002Freleases\u002F) and [Laravel 13.5+](https:\u002F\u002Flaravel.com)**\n\n## Installation\n\n```bash\ncomposer require nunomaduro\u002Flaravel-sluggable\n```\n\n## Getting Started\n\nTo make an existing model sluggable, run the **`make:sluggable`** Artisan command:\n\n```bash\nphp artisan make:sluggable Post\n```\n\nThis command adds the `#[Sluggable]` attribute to your model and generates a migration for the slug column. It introspects the model's table to guess the source column (`name`, `title`, `headline`, or `subject`):\n\n```diff\n+use NunoMaduro\\LaravelSluggable\\Attributes\\Sluggable;\n\n+#[Sluggable(from: 'title')]\nclass Post extends Model\n{\n}\n```\n\nIt also generates a migration under `database\u002Fmigrations` that adds the slug column:\n\n```php\nSchema::table('posts', function (Blueprint $table) {\n    $table\n        ->string('slug')\n    \u002F\u002F  ->nullable()\n        ->unique()\n        ->after('id');\n});\n```\n\n**Review the migration before running it.** The right shape depends on how you configured the attribute and the state of your existing data. For example, on a table with existing rows you typically want to use the `->nullable()`, etc.\n\nOnce the migration is in shape, run:\n\n```bash\nphp artisan migrate\n```\n\nWhen a `Post` is created, a slug will be automatically generated and stored in the `slug` column:\n\n```php\n$post = Post::create(['title' => 'Hello World']);\n$post->slug; \u002F\u002F \"hello-world\"\n```\n\nThe command also accepts `--from` and `--to` options:\n\n```bash\nphp artisan make:sluggable Post --from=headline --to=url_slug\n```\n\n## Configuration\n\nEvery aspect of slug generation can be customized directly on the attribute.\n\n### `from`\n\nBy default, the slug is generated from the `name` column. You may customize this with the `from` parameter:\n\n```php\n#[Sluggable(from: 'title')]\n```\n\nSlugs may also be generated from multiple columns by passing an array:\n\n```php\n#[Sluggable(from: ['first_name', 'last_name'])]\nclass Author extends Model\n{\n}\n\n$author = Author::create(['first_name' => 'John', 'last_name' => 'Doe']);\n$author->slug; \u002F\u002F \"john-doe\"\n```\n\n### `to`\n\nBy default, the slug is stored in the `slug` column. You may customize this with the `to` parameter:\n\n```php\n#[Sluggable(from: 'title', to: 'url_slug')]\n```\n\n### `scope`\n\nWhen slugs should be unique within a scope (for example, per team or per locale), pass one or more scope columns:\n\n```php\n#[Sluggable(scope: 'team_id')]\n```\n\nMultiple scope columns are also supported:\n\n```php\n#[Sluggable(scope: ['team_id', 'locale'])]\n```\n\n### `onUpdating`, `separator`, `unique`, `maxAttempts`, `maxLength`\n\nThe attribute accepts several other options to fine-tune slug generation. By default, slugs are generated on creation but not on update, use `-` as the separator, enforce uniqueness with up to 100 attempts, and have no maximum length:\n\n```php\n#[Sluggable(\n    onUpdating: false,\n    separator: '-',\n    unique: true,\n    maxAttempts: 100,\n    maxLength: 60,\n)]\n```\n\nWhen `onUpdating` is enabled, the slug is regenerated whenever any source column changes. When a slug value is manually provided, it is always preserved — both on creation and on update.\n\n### `errorKey`\n\nWhen slug generation fails, a `CouldNotGenerateSlugException` is thrown. In HTTP contexts, this exception renders automatically as a `422` validation error response — just like a failed validation rule. The error is attached to the first source column by default:\n\n```json\n{\n    \"errors\": {\n        \"name\": [\"The name cannot be converted into a valid slug.\"]\n    }\n}\n```\n\nYou may customize the error key using the `errorKey` parameter:\n\n```php\n#[Sluggable(errorKey: 'input_name')]\n```\n\nError messages may be customized by defining `validation.slug_required` and `validation.slug_unique` keys in your application's language files. Both keys receive `:attribute` and `:slug` replacements:\n\n```php\n\u002F\u002F lang\u002Fen\u002Fvalidation.php\n'slug_required' => 'The :attribute cannot be converted into a valid :slug.',\n'slug_unique' => 'Too many :slug entries exist for the given :attribute. Please try a different value.',\n```\n\nBecause it extends `ValidationException`, the exception is not reported to the application log — consistent with how Laravel handles `ModelNotFoundException` and other Eloquent exceptions.\n\n## Slug Generation Pipeline\n\nThe pipeline has **first-class Unicode and CJK support** — non-Latin scripts transliterate to readable Latin slugs (`如何安装 Laravel` → `ru-he-an-zhuang-laravel`).\n\nIt's also **domain-aware**: values like `laravel.com`, `sub.domain.example.com`, `document.final.pdf`, and `über.straße` keep their dots intact — most generators flatten them.\n\nA few examples:\n\n| Input                               | Slug                              |\n|-------------------------------------|-----------------------------------|\n| `Hello World`                       | `hello-world`                     |\n| `Café Résumé`                       | `cafe-resume`                     |\n| `Straße`                            | `strasse`                         |\n| `如何安装 Laravel`                    | `ru-he-an-zhuang-laravel`         |\n| `こんにちは`                          | `konnichiha`                      |\n| `안녕하세요`                          | `annyeonghaseyo`                  |\n| `Привет Мир`                        | `privet-mir`                      |\n| `laravel.com`                       | `laravel.com`                     |\n| `sub.domain.example.com`            | `sub.domain.example.com`          |\n| `document.final.pdf`                | `document.final.pdf`              |\n| `über.straße`                       | `uber.strasse`                    |\n| `Example\u002FPath`                      | `example-path`                    |\n| `Hello — World`                     | `hello-world`                     |\n| `🎉 Hello 🌟 World 🚀`              | `hello-world`                     |\n| `[2024] Annual Report (Final)`      | `2024-annual-report-final`        |\n\n---\n\n**Laravel Sluggable** was created by **[Nuno Maduro](https:\u002F\u002Fx.com\u002Fenunomaduro)** under the **[MIT license](https:\u002F\u002Fopensource.org\u002Flicenses\u002FMIT)**.\n","Laravel Sluggable 是一个用于 Eloquent 模型自动生成 slug 的库。它通过在模型上添加 `#[Sluggable]` 属性即可实现自动化的 slug 生成，无需额外的 trait 或基类。该库处理了多种复杂情况，包括 slug 冲突、Unicode 和 CJK 转写、域感知点保留、范围唯一性（按租户或语言环境）、多列来源以及软删除记录冲突等。适用于需要为 Laravel 应用中的模型生成唯一且友好的 URL 标识符的场景。项目要求 PHP 8.5+ 和 Laravel 13.5+ 版本。","2026-06-11 02:47:50","CREATED_QUERY"]