https://github.com/mazbaul/comp
A composite key validation package for laravel
https://github.com/mazbaul/comp
composite-key database laravel laravel-package php validation
Last synced: 5 months ago
JSON representation
A composite key validation package for laravel
- Host: GitHub
- URL: https://github.com/mazbaul/comp
- Owner: Mazbaul
- Created: 2020-02-12T07:16:15.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-27T07:09:45.000Z (almost 6 years ago)
- Last Synced: 2025-04-05T14:22:15.818Z (about 1 year ago)
- Topics: composite-key, database, laravel, laravel-package, php, validation
- Language: PHP
- Size: 10.7 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# composite_unique Validator Rule For Laravel
This package contains composite key validation rule for Laravel, that allows for validation of multi-column UNIQUE indexes.
## Installation
Install the package through [Composer](http://getcomposer.org).
On the command line:
```
composer require mazbaul/comp
```
## Configuration
Add the following to your `providers` array in `config/app.php`:
```php
'providers' => [
// ...
Mazbaul\Comp\CompServiceProvider::class,
],
```
## Usage
Use it like any `Validator` rule:
```php
$validator = Validator::make($request->all(), [
"" =>'required|composite_unique:,,',
]);
```
See the [Validation documentation](http://laravel.com/docs/validation) of Laravel.
### Ignore existing row (useful when updating)
You can also specify a row id to ignore (useful to solve unique constraint when updating)
This will ignore row with id 2
```php
$validator = Validator::make($request->all(), [
"" =>'required|composite_unique:,,,ignore--'.$id,
]);
```
# License
MIT