PHP code example of topview-digital / laravel-unique-json-rule
1. Go to this page and download the library: Download topview-digital/laravel-unique-json-rule library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
topview-digital / laravel-unique-json-rule example snippets
$attributes = request()->validate([
'contact.name' => 'unique_json:clients,contact->name',
'contact.email' => UniqueJsonRule::for('clients','contact->email'),
]);
$attributes = request()->validate([
'contact.name' => 'unique_json:clients,contact->name,{$client->id}',
'contact.email' => UniqueJsonRule::for('clients','contact->email')->ignore($client->id),
]);
$attributes = request()->validate([
'contact.name' => 'unique_json:clients,contact->name,{$client->uuid},uuid',
'contact.email' => UniqueJsonRule::for('clients','contact->email')->ignore($client->uuid,'uuid'),
]);
$attributes = request()->validate([
'contact.name' => 'unique_json:clients,contact->name,{$client->id}',
], [
'contact.name.unique_json' => 'Your custom :attribute error.',
]);