{"id":36977839,"url":"https://github.com/mattvb91/uniquewith-validator","last_synced_at":"2026-01-13T22:47:10.411Z","repository":{"id":61806929,"uuid":"555279823","full_name":"mattvb91/uniquewith-validator","owner":"mattvb91","description":"Custom Laravel Validator for combined unique indexes","archived":true,"fork":true,"pushed_at":"2022-10-21T09:36:48.000Z","size":110,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-09-27T06:37:58.812Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"laravel-shift/uniquewith-validator","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mattvb91.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-10-21T09:16:55.000Z","updated_at":"2023-01-27T19:59:17.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/mattvb91/uniquewith-validator","commit_stats":null,"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"purl":"pkg:github/mattvb91/uniquewith-validator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattvb91%2Funiquewith-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattvb91%2Funiquewith-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattvb91%2Funiquewith-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattvb91%2Funiquewith-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattvb91","download_url":"https://codeload.github.com/mattvb91/uniquewith-validator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattvb91%2Funiquewith-validator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28403168,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-13T22:47:10.286Z","updated_at":"2026-01-13T22:47:10.392Z","avatar_url":"https://github.com/mattvb91.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# THIS IS NOT MAINTAINED. THIS IS JUST TO GET THE LARAVEL 9 UPDATE WORKING. SEE https://github.com/mattvb91/uniquewith-validator/commit/ba133e734ca8e71f4218f0e1db88a1bbc5a583e7 DUE TO THE MAINTAINER ABANDONING THE PACKAGE.\n# unique_with Validator Rule For Laravel\n\n[![Build Status](https://travis-ci.org/felixkiss/uniquewith-validator.svg?branch=master)](https://travis-ci.org/felixkiss/uniquewith-validator)\n\nThis package contains a variant of the `validateUnique` rule for Laravel, that allows for validation of multi-column UNIQUE indexes.\n\n## Documentation for older versions\n\n - [Laravel 4](https://github.com/felixkiss/uniquewith-validator/blob/2.0.8/README.md#laravel-4)\n\n## Installation\n\nInstall the package through [Composer](http://getcomposer.org).\nOn the command line:\n\n```\ncomposer require mattvb91/uniquewith-validator\n```\n\n## Configuration\n\nAdd the following to your `providers` array in `config/app.php`:\n\n```php\n'providers' =\u003e [\n    // ...\n\n    Felixkiss\\UniqueWithValidator\\ServiceProvider::class,\n],\n```\n\n## Usage\n\nUse it like any `Validator` rule:\n\n```php\n$rules = [\n    '\u003cfield1\u003e' =\u003e 'unique_with:\u003ctable\u003e,\u003cfield2\u003e[,\u003cfield3\u003e,...,\u003cignore_rowid\u003e]',\n];\n```\n\nSee the [Validation documentation](http://laravel.com/docs/validation) of Laravel.\n\n### Specify different column names in the database\n\nIf your input field names are different from the corresponding database columns,\nyou can specify the column names explicitly.\n\ne.g. your input contains a field 'last_name', but the column in your database is called 'sur_name':\n```php\n$rules = [\n    'first_name' =\u003e 'unique_with:users, middle_name, last_name = sur_name',\n];\n```\n\n### Ignore existing row (useful when updating)\n\nYou can also specify a row id to ignore (useful to solve unique constraint when updating)\n\nThis will ignore row with id 2\n\n```php\n$rules = [\n    'first_name' =\u003e 'required|unique_with:users,last_name,2',\n    'last_name' =\u003e 'required',\n];\n```\n\nTo specify a custom column name for the id, pass it like\n\n```php\n$rules = [\n    'first_name' =\u003e 'required|unique_with:users,last_name,2 = custom_id_column',\n    'last_name' =\u003e 'required',\n];\n```\n\nIf your id is not numeric, you can tell the validator\n\n```php\n$rules = [\n    'first_name' =\u003e 'required|unique_with:users,last_name,ignore:abc123',\n    'last_name' =\u003e 'required',\n];\n```\n\n### Add additional clauses (e.g. when using soft deletes)\n\nYou can also set additional clauses. For example, if your model uses soft deleting\nthen you can use the following code to select all existing rows but marked as deleted\n\n```php\n$rules = [\n    'first_name' =\u003e 'required|unique_with:users,last_name,deleted_at,2 = custom_id_column',\n    'last_name' =\u003e 'required',\n];\n```\n\n*Soft delete caveat:*\n\nIn Laravel 5 (tested on 5.5), if the validation is performed in form request class, field deleted_at is skipped, because it's not send in request. To solve this problem, add 'deleted_at' =\u003e null to Your validation parameters in request class., e.g.:\n\n```php\nprotected function validationData()\n{\n    return array_merge($this-\u003erequest-\u003eall(), [\n        'deleted_at' =\u003e null\n    ]);\n}\n```\n\n### Specify specific database connection to use\n\nIf we have a connection named `some-database`, we can enforce this connection (rather than the default) like this:\n\n```php\n$rules = [\n    'first_name' =\u003e 'unique_with:some-database.users, middle_name, last_name',\n];\n```\n\n## Example\n\nPretend you have a `users` table in your database plus `User` model like this:\n\n```php\n\u003c?php\n\nuse Illuminate\\Database\\Migrations\\Migration;\nuse Illuminate\\Database\\Schema\\Blueprint;\n\nclass CreateUsersTable extends Migration {\n\n    /**\n     * Run the migrations.\n     *\n     * @return void\n     */\n    public function up()\n    {\n        Schema::create('users', function(Blueprint $table) {\n            $table-\u003eincrements('id');\n\n            $table-\u003etimestamps();\n\n            $table-\u003estring('first_name');\n            $table-\u003estring('last_name');\n\n            $table-\u003eunique(['first_name', 'last_name']);\n        });\n    }\n\n    /**\n     * Reverse the migrations.\n     *\n     * @return void\n     */\n    public function down()\n    {\n        Schema::drop('users');\n    }\n\n}\n```\n\n```php\n\u003c?php\n\nclass User extends Eloquent { }\n```\n\nNow you can validate a given `first_name`, `last_name` combination with something like this:\n\n```php\nRoute::post('test', function() {\n    $rules = [\n        'first_name' =\u003e 'required|unique_with:users,last_name',\n        'last_name' =\u003e 'required',\n    ];\n\n    $validator = Validator::make(Input::all(), $rules);\n\n    if($validator-\u003efails()) {\n        return Redirect::back()-\u003ewithErrors($validator);\n    }\n\n    $user = new User;\n    $user-\u003efirst_name = Input::get('first_name');\n    $user-\u003elast_name = Input::get('last_name');\n    $user-\u003esave();\n\n    return Redirect::home()-\u003ewith('success', 'User created!');\n});\n```\n\n# License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattvb91%2Funiquewith-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattvb91%2Funiquewith-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattvb91%2Funiquewith-validator/lists"}