{"id":21541854,"url":"https://github.com/labrodev/laravel-numberable","last_synced_at":"2026-02-09T15:33:02.213Z","repository":{"id":262092842,"uuid":"819085285","full_name":"labrodev/laravel-numberable","owner":"labrodev","description":"Numberable is a Laravel package that provides a reusable trait for automatically assigning a number to Eloquent models upon their creation.","archived":false,"fork":false,"pushed_at":"2025-08-03T09:29:01.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-12T03:07:52.851Z","etag":null,"topics":["eloquent","eloquent-models","laravel","laravel-framework","laravel-package","php-library","traits"],"latest_commit_sha":null,"homepage":"https://substack.com/@labrodev/p-151452747","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/labrodev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2024-06-23T18:26:25.000Z","updated_at":"2025-08-03T09:27:33.000Z","dependencies_parsed_at":"2024-11-10T14:20:55.775Z","dependency_job_id":"72a36245-0557-474a-985f-99943c734008","html_url":"https://github.com/labrodev/laravel-numberable","commit_stats":null,"previous_names":["labrodev/laravel-numberable"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/labrodev/laravel-numberable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labrodev%2Flaravel-numberable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labrodev%2Flaravel-numberable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labrodev%2Flaravel-numberable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labrodev%2Flaravel-numberable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/labrodev","download_url":"https://codeload.github.com/labrodev/laravel-numberable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labrodev%2Flaravel-numberable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29270905,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-09T13:47:44.167Z","status":"ssl_error","status_checked_at":"2026-02-09T13:47:43.721Z","response_time":56,"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":["eloquent","eloquent-models","laravel","laravel-framework","laravel-package","php-library","traits"],"created_at":"2024-11-24T05:07:51.472Z","updated_at":"2026-02-09T15:33:02.184Z","avatar_url":"https://github.com/labrodev.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Numberable for Laravel\n\nNumberable is a Laravel package that provides a reusable trait for automatically assigning a number to Eloquent models upon their creation.\n\nBy default it generates a unique document number based on the model's ID and the current year. This method can be customized in individual models that use the trait, allowing for flexible document numbering logic.\n\n- Base Year: Uses the current year as the prefix for the document number.\n- Prediction Number: Sets a default \"prediction number\" (e.g., 10000), determining the minimum length of the number portion.\n- Padding: Pads the model ID with leading zeros to match the length of the prediction number, ensuring consistent document number lengths.\n\nFor example, if the current year is 2024 and the model ID is 45 and prediction number is 10000, the generated document number would be: 202400045.\n\nBut you are free to provide your own logic of generation for specific models. \n\nYou just need to overwrite method `protected function generateNumberByTraitModelHasNumber(int $modelId): string` in your model. \n\n## Installation\n\nTo install the package, run the following command in your Laravel project:\n\n```bash\ncomposer require labrodev/numberable\n```\n\n## Requirements\n\n- PHP 8.1 or higher\n\n## Configuration\n\nAfter installing the package, no additional configuration is needed to start using the UUID trait in your models.\n\n## Usage\n\nTo use the `ModelHasNumber` trait, simply include it in your Eloquent model:\n\n```php \n\n\u003c?php\n\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Labrodev\\Numberable\\ModelHasNumber;\n\nclass ExampleModel extends Model\n{\n    use ModelHasNumber;\n}\n```\n\nEnsure that your model has 'number' column in model database table. \n\nIf it is not, you may add it through Laravel migration: \n\n```php\n$table-\u003estring('number');\n```\n\n## Override number column name\n\nIf the column in your database table designated for document number storage has a name different from the default, you can customize the trait to accommodate this. \n\nSimply override the trait method in your model by adding the following method with your specific column name:\n\n```php \n/**\n* @return string\n*/\nprotected function modelHasNumberTraitColumn(): string\n{\n    return 'your-number-column-name';\n}\n```\n\n## Overwrite logic of number generation\n\nYou may overwrite logic of number generation by customize logic in overwritten method in your model:\n\n```php \n/**\n* @return string\n*/\nprotected function generateNumberByTraitModelHasNumber(int $modelId): string\n{\n    // your own logic to generate a number \n}\n```\n\nIf you want to keep basic logic by generating number based on current year + prediction number + model ID,\nbut there is a necessity to adjust prediction number value, you may add method to your model:\n\n```php\nprotected function predictionNumberForTraitModelHasNumber(): int \n{\n   return 10000; // your prediction number\n}\n```\n\n## Testing\n\nTo run the tests included with the package, execute the following command:\n\n```bash\ncomposer test\n```\n\nFor static analysis to check the package code, execute the followin command: \n\n```bash\ncomposer analyse\n```\n\n## Security\n\nIf you discover any security-related issues, please email admin@labrodev.com instead of using the issue tracker.\n\n## Credits\n\nLabro Dev\n\n## License\n\nThe MIT License (MIT). Please see License File for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flabrodev%2Flaravel-numberable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flabrodev%2Flaravel-numberable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flabrodev%2Flaravel-numberable/lists"}