Skip to content

Commit

Permalink
unique_encrypted and exists_encrypted key issue fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhara committed Jan 22, 2024
1 parent c223c1b commit 24bf8f1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Traits/ValidatesEncrypted.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function addValidators()
$field = isset($parameters[1]) ? $parameters[1] : $attribute;
$ignore = isset($parameters[2]) ? $parameters[2] : null;

$items = DB::select("SELECT count(*) as aggregate FROM `" . $parameters[0] . "` WHERE AES_DECRYPT(`" . $field . "`, '" . config("app.key") . "') LIKE '" . $value . "' COLLATE utf8mb4_general_ci" . ($ignore ? " AND id != " . $ignore : ''));
$items = DB::select("SELECT count(*) as aggregate FROM `" . $parameters[0] . "` WHERE AES_DECRYPT(`" . $field . "`, '" . config("mysql-encrypt.key") . "') LIKE '" . $value . "' COLLATE utf8mb4_general_ci" . ($ignore ? " AND id != " . $ignore : ''));

return $items[0]->aggregate == 0;
});
Expand All @@ -39,7 +39,7 @@ public function addValidators()

$field = isset($parameters[1]) ? $parameters[1] : $attribute;

$items = DB::select("SELECT count(*) as aggregate FROM `" . $parameters[0] . "` WHERE AES_DECRYPT(`" . $field . "`, '" . config("app.key") . "') LIKE '" . $value . "' COLLATE utf8mb4_general_ci");
$items = DB::select("SELECT count(*) as aggregate FROM `" . $parameters[0] . "` WHERE AES_DECRYPT(`" . $field . "`, '" . config("mysql-encrypt.key") . "') LIKE '" . $value . "' COLLATE utf8mb4_general_ci");

return $items[0]->aggregate > 0;
});
Expand Down

0 comments on commit 24bf8f1

Please sign in to comment.