{"id":23980775,"url":"https://github.com/tailflow/laravel-human-readable-keys","last_synced_at":"2025-04-14T04:33:59.697Z","repository":{"id":57064580,"uuid":"335870360","full_name":"tailflow/laravel-human-readable-keys","owner":"tailflow","description":"Generate Stripe-like IDs for Eloquent models","archived":false,"fork":false,"pushed_at":"2022-12-19T16:09:45.000Z","size":9,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-09-22T19:36:45.476Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":false,"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/tailflow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-04T07:12:19.000Z","updated_at":"2024-09-16T11:51:53.000Z","dependencies_parsed_at":"2023-01-29T22:15:15.997Z","dependency_job_id":null,"html_url":"https://github.com/tailflow/laravel-human-readable-keys","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tailflow%2Flaravel-human-readable-keys","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tailflow%2Flaravel-human-readable-keys/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tailflow%2Flaravel-human-readable-keys/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tailflow%2Flaravel-human-readable-keys/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tailflow","download_url":"https://codeload.github.com/tailflow/laravel-human-readable-keys/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248495579,"owners_count":21113656,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2025-01-07T10:18:36.029Z","updated_at":"2025-04-14T04:33:59.676Z","avatar_url":"https://github.com/tailflow.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Human Readable Keys\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/tailflow/laravel-human-readable-keys.svg)](https://packagist.org/packages/tailflow/laravel-human-readable-keys)\n[![Build Status on Github Actions](https://img.shields.io/github/actions/workflow/status/tailflow/laravel-human-readable-keys/ci.yml?branch=main)](https://github.com/tailflow/laravel-human-readable-keys/actions)\n\nHave you ever wanted to generate Stripe-like IDs for your Eloquent models? This package does exactly that!\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require tailflow/laravel-human-readable-keys\n```\n\n## Usage\n\n1. Change type of the `id` (or whatever your primary key column is) to `string` in the migration\n\n```php\nSchema::create('users', function (Blueprint $table) {\n    $table-\u003estring('id');\n    \n    ...\n});\n```\n\n2. Add `HasHumanReadableKey` trait to a model\n\n```php\n\u003c?php\n\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Tailflow\\HumanReadableKeys\\Concerns\\HasHumanReadableKey;\n\nclass User extends Model\n{\n    use HasHumanReadableKey;\n\n   ...\n}\n```\n\n3. (Optional) Customize key prefix and length\n\nBy default, a singular form of the table name is used as prefix for generated keys. You can customize that by overriding\nthe `getKeyPrefix` method on the model:\n\n```php\n\u003c?php\n\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Tailflow\\HumanReadableKeys\\Concerns\\HasHumanReadableKey;\n\nclass User extends Model\n{\n    use HasHumanReadableKey;\n\n   ...\n   \n    public function getKeyPrefix(): string\n    {\n        return 'account';\n    }\n}\n```\n\nGenerated keys contain a unique hash that is 24 characters in length. To customize hash length, override the `getKeyLength` method:\n\n```php\n\u003c?php\n\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Tailflow\\HumanReadableKeys\\Concerns\\HasHumanReadableKey;\n\nclass User extends Model\n{\n    use HasHumanReadableKey;\n\n   ...\n   \n    public function getKeyLength(): string\n    {\n        return 16;\n    }\n}\n```\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%2Ftailflow%2Flaravel-human-readable-keys","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftailflow%2Flaravel-human-readable-keys","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftailflow%2Flaravel-human-readable-keys/lists"}