@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | */ |
| 219 | 219 | public function scopeWhereEncrypted($query, $column, $value) |
| 220 | 220 | { |
| 221 | - return $query->whereRaw('AES_DECRYPT('.$column.', "'.getenv('ENCRYPTION_KEY').'") LIKE ? COLLATE utf8mb4_general_ci', [$value]); |
|
| 221 | + return $query->whereRaw('AES_DECRYPT(' . $column . ', "' . getenv('ENCRYPTION_KEY') . '") LIKE ? COLLATE utf8mb4_general_ci', [$value]); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | /** |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | public function scopeWhereNotEncrypted($query, $column, $value) |
| 234 | 234 | { |
| 235 | - return $query->whereRaw('AES_DECRYPT('.$column.', "'.getenv('ENCRYPTION_KEY').'") NOT LIKE ? COLLATE utf8mb4_general_ci', [$value]); |
|
| 235 | + return $query->whereRaw('AES_DECRYPT(' . $column . ', "' . getenv('ENCRYPTION_KEY') . '") NOT LIKE ? COLLATE utf8mb4_general_ci', [$value]); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | /** |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | */ |
| 247 | 247 | public function scopeOrWhereEncrypted($query, $column, $value) |
| 248 | 248 | { |
| 249 | - return $query->orWhereRaw('AES_DECRYPT('.$column.', "'.getenv('ENCRYPTION_KEY').'") LIKE ? COLLATE utf8mb4_general_ci', [$value]); |
|
| 249 | + return $query->orWhereRaw('AES_DECRYPT(' . $column . ', "' . getenv('ENCRYPTION_KEY') . '") LIKE ? COLLATE utf8mb4_general_ci', [$value]); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | public function scopeOrWhereNotEncrypted($query, $column, $value) |
| 262 | 262 | { |
| 263 | - return $query->orWhereRaw('AES_DECRYPT('.$column.', "'.getenv('ENCRYPTION_KEY').'") NOT LIKE ? COLLATE utf8mb4_general_ci', [$value]); |
|
| 263 | + return $query->orWhereRaw('AES_DECRYPT(' . $column . ', "' . getenv('ENCRYPTION_KEY') . '") NOT LIKE ? COLLATE utf8mb4_general_ci', [$value]); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | /** |
@@ -274,6 +274,6 @@ discard block |
||
| 274 | 274 | */ |
| 275 | 275 | public function scopeOrderByEncrypted($query, $column, $direction) |
| 276 | 276 | { |
| 277 | - return $query->orderByRaw('AES_DECRYPT('.$column.', "'.getenv('ENCRYPTION_KEY').'") '.$direction); |
|
| 277 | + return $query->orderByRaw('AES_DECRYPT(' . $column . ', "' . getenv('ENCRYPTION_KEY') . '") ' . $direction); |
|
| 278 | 278 | } |
| 279 | 279 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | /** |
| 29 | 29 | * Validate unique binary encrypted |
| 30 | 30 | */ |
| 31 | - Validator::extend('unique_encrypted', function ($attribute, $value, array $parameters) { |
|
| 31 | + Validator::extend('unique_encrypted', function($attribute, $value, array $parameters) { |
|
| 32 | 32 | if (!isset($parameters[0])) { |
| 33 | 33 | throw new Exception('unique_encrypted requires at least one parameter'); |
| 34 | 34 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | $field = isset($parameters[1]) ? $parameters[1] : $attribute; |
| 37 | 37 | $ignore = isset($parameters[2]) ? $parameters[2] : null; |
| 38 | 38 | |
| 39 | - $items = DB::select("SELECT count(*) as aggregate FROM `".$parameters[0]."` WHERE AES_DECRYPT(`".$field."`, '".getenv("ENCRYPTION_KEY")."') LIKE ? COLLATE utf8mb4_general_ci".($ignore ? " AND id != ".$ignore : ''), |
|
| 39 | + $items = DB::select("SELECT count(*) as aggregate FROM `" . $parameters[0] . "` WHERE AES_DECRYPT(`" . $field . "`, '" . getenv("ENCRYPTION_KEY") . "') LIKE ? COLLATE utf8mb4_general_ci" . ($ignore ? " AND id != " . $ignore : ''), |
|
| 40 | 40 | [$value]); |
| 41 | 41 | |
| 42 | 42 | return $items[0]->aggregate === 0; |
@@ -45,14 +45,14 @@ discard block |
||
| 45 | 45 | /** |
| 46 | 46 | * Validate exists binary encrypted |
| 47 | 47 | */ |
| 48 | - Validator::extend('exists_encrypted', function ($attribute, $value, array $parameters) { |
|
| 48 | + Validator::extend('exists_encrypted', function($attribute, $value, array $parameters) { |
|
| 49 | 49 | if (!isset($parameters[0])) { |
| 50 | 50 | throw new Exception('exists_encrypted requires at least one parameter'); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | $field = isset($parameters[1]) ? $parameters[1] : $attribute; |
| 54 | 54 | |
| 55 | - $items = DB::select("SELECT count(*) as aggregate FROM `".$parameters[0]."` WHERE AES_DECRYPT(`".$field."`, '".getenv("ENCRYPTION_KEY")."') LIKE ? COLLATE utf8mb4_general_ci", |
|
| 55 | + $items = DB::select("SELECT count(*) as aggregate FROM `" . $parameters[0] . "` WHERE AES_DECRYPT(`" . $field . "`, '" . getenv("ENCRYPTION_KEY") . "') LIKE ? COLLATE utf8mb4_general_ci", |
|
| 56 | 56 | [$value]); |
| 57 | 57 | |
| 58 | 58 | return $items[0]->aggregate > 0; |