Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 7 days 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 (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-07-27T07:09:45.000Z (over 4 years ago)
- Last Synced: 2024-10-12T11:13:31.926Z (about 1 month ago)
- Topics: composite-key, database, laravel, laravel-package, php, validation
- Language: PHP
- Size: 10.7 KB
- Stars: 3
- Watchers: 2
- 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