https://github.com/julianstark999/laravel-model-iid
A Laravel package to have an internal ID (displayable in the UI), that's unique in the scope of a relationship
https://github.com/julianstark999/laravel-model-iid
eloquent eloquent-models iid iids laravel laravel-model laravel-model-iid laravel-package laravel8 php
Last synced: about 1 month ago
JSON representation
A Laravel package to have an internal ID (displayable in the UI), that's unique in the scope of a relationship
- Host: GitHub
- URL: https://github.com/julianstark999/laravel-model-iid
- Owner: julianstark999
- License: mit
- Created: 2021-01-06T17:19:45.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-04-18T14:59:12.000Z (about 3 years ago)
- Last Synced: 2025-02-11T08:49:54.464Z (3 months ago)
- Topics: eloquent, eloquent-models, iid, iids, laravel, laravel-model, laravel-model-iid, laravel-package, laravel8, php
- Language: PHP
- Homepage:
- Size: 67.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
[](https://packagist.org/packages/julianstark999/laravel-model-iid)
[](https://github.com/julianstark999/laravel-model-iid/actions?query=workflow%3ATests+branch%3Amaster)
[](https://github.com/julianstark999/laravel-model-iid/actions?query=workflow%3A"Check+%26+fix+styling"+branch%3Amaster)
[](https://packagist.org/packages/julianstark999/laravel-model-iid)# Add an internal ID to your Eloquent Model
This Laravel package provides the functionality to have an internal ID (displayable in the UI), that's unique in the scope of a relationship## Installation
You can install the package via composer:
```bash
composer require julianstark999/laravel-model-iid
```## Usage
### Model
```php
unsignedInteger('iid')->nullable();// optional (should only be defined for new tables or after generating iids for existing entries)
$table->unique(['project_id', 'iid']);
```### Commands
#### iid:generate
The `iid:generate` command generates missing iid for existing models
```bash
php artisan iid:generate {className}# example
php artisan iid:generate "App\Models\Task"
```#### iid:init
The `iid:init` command initializes the iid for existing models by using the id column
```bash
php artisan iid:generate {className}# example
php artisan iid:init "App\Models\Task"
```
*Recommended using if you already use the `id` column for display*### Testing
``` bash
composer test
```### Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## Contributing
Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.
## Credits
- [Julian Stark](https://github.com/julianstark999)
- [All Contributors](../../contributors)## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.