Skip to content

Instantly share code, notes, and snippets.

@M-Abdullahi
Last active November 29, 2019 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save M-Abdullahi/4814cd005d9c7a1a86c88d4035c838ae to your computer and use it in GitHub Desktop.
Save M-Abdullahi/4814cd005d9c7a1a86c88d4035c838ae to your computer and use it in GitHub Desktop.
Validator::extend('encrypted_unique', function ($attribute, $value, $parameters, $validator) {
list ($table, $column, $ignore_id) = $parameters; // or hard-coded if fixed
$count = $validator->getPresenceVerifier()->getCount($table, $column, encrypt($value), $ignore_id);
return $count === 0;
});
'identifier' => "encrypted_unique:table,column,$this_id"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment