Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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 (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-04-18T14:59:12.000Z (almost 3 years ago)
- Last Synced: 2024-12-15T11:48:08.005Z (about 1 month 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
[![Latest Version on Packagist](https://img.shields.io/packagist/v/julianstark999/laravel-model-iid.svg?style=flat-square)](https://packagist.org/packages/julianstark999/laravel-model-iid)
[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/julianstark999/laravel-model-iid/run-tests?label=tests)](https://github.com/julianstark999/laravel-model-iid/actions?query=workflow%3ATests+branch%3Amaster)
[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/julianstark999/laravel-model-iid/Check%20&%20fix%20styling?label=code%20style)](https://github.com/julianstark999/laravel-model-iid/actions?query=workflow%3A"Check+%26+fix+styling"+branch%3Amaster)
[![Total Downloads](https://img.shields.io/packagist/dt/julianstark999/laravel-model-iid.svg?style=flat-square)](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.