Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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