@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | public function scopeWhereEncrypted($query, $column, $value) |
224 | 224 | { |
225 | 225 | /** @var Builder $query */ |
226 | - return $query->whereRaw('AES_DECRYPT('.$column.', "'.getenv("ENCRYPTION_KEY").'") LIKE "'.$value.'" COLLATE utf8mb4_general_ci'); |
|
226 | + return $query->whereRaw('AES_DECRYPT(' . $column . ', "' . getenv("ENCRYPTION_KEY") . '") LIKE "' . $value . '" COLLATE utf8mb4_general_ci'); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | public function scopeWhereNotEncrypted($query, $column, $value) |
239 | 239 | { |
240 | 240 | /** @var Builder $query */ |
241 | - return $query->whereRaw('AES_DECRYPT('.$column.', "'.getenv("ENCRYPTION_KEY").'") NOT LIKE "'.$value.'" COLLATE utf8mb4_general_ci'); |
|
241 | + return $query->whereRaw('AES_DECRYPT(' . $column . ', "' . getenv("ENCRYPTION_KEY") . '") NOT LIKE "' . $value . '" COLLATE utf8mb4_general_ci'); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | public function scopeOrWhereEncrypted($query, $column, $value) |
254 | 254 | { |
255 | 255 | /** @var Builder $query */ |
256 | - return $query->orWhereRaw('AES_DECRYPT('.$column.', "'.getenv("ENCRYPTION_KEY").'") LIKE "'.$value.'" COLLATE utf8mb4_general_ci'); |
|
256 | + return $query->orWhereRaw('AES_DECRYPT(' . $column . ', "' . getenv("ENCRYPTION_KEY") . '") LIKE "' . $value . '" COLLATE utf8mb4_general_ci'); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | public function scopeOrWhereNotEncrypted($query, $column, $value) |
269 | 269 | { |
270 | 270 | /** @var Builder $query */ |
271 | - return $query->orWhereRaw('AES_DECRYPT('.$column.', "'.getenv("ENCRYPTION_KEY").'") NOT LIKE "'.$value.'" COLLATE utf8mb4_general_ci'); |
|
271 | + return $query->orWhereRaw('AES_DECRYPT(' . $column . ', "' . getenv("ENCRYPTION_KEY") . '") NOT LIKE "' . $value . '" COLLATE utf8mb4_general_ci'); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -283,6 +283,6 @@ discard block |
||
283 | 283 | public function scopeOrderByEncrypted($query, $column, $direction) |
284 | 284 | { |
285 | 285 | /** @var Builder $query */ |
286 | - return $query->orderByRaw('AES_DECRYPT('.$column.', "'.getenv("ENCRYPTION_KEY").'") '.$direction); |
|
286 | + return $query->orderByRaw('AES_DECRYPT(' . $column . ', "' . getenv("ENCRYPTION_KEY") . '") ' . $direction); |
|
287 | 287 | } |
288 | 288 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * Validate unique binary encrypted |
32 | 32 | */ |
33 | - Validator::extend('unique_encrypted', function ($attribute, $value, array $parameters) { |
|
33 | + Validator::extend('unique_encrypted', function($attribute, $value, array $parameters) { |
|
34 | 34 | if (!isset($parameters[0])) { |
35 | 35 | throw new Exception('unique_encrypted requires at least one parameter'); |
36 | 36 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | $field = isset($parameters[1]) ? $parameters[1] : $attribute; |
39 | 39 | $ignore = isset($parameters[2]) ? $parameters[2] : null; |
40 | 40 | |
41 | - $items = DB::select("SELECT count(*) as aggregate FROM `".$parameters[0]."` WHERE AES_DECRYPT(`".$field."`, '".getenv("ENCRYPTION_KEY")."') LIKE '".$value."' COLLATE utf8mb4_general_ci".($ignore ? " AND id != ".$ignore : '')); |
|
41 | + $items = DB::select("SELECT count(*) as aggregate FROM `" . $parameters[0] . "` WHERE AES_DECRYPT(`" . $field . "`, '" . getenv("ENCRYPTION_KEY") . "') LIKE '" . $value . "' COLLATE utf8mb4_general_ci" . ($ignore ? " AND id != " . $ignore : '')); |
|
42 | 42 | |
43 | 43 | return $items[0]->aggregate === 0; |
44 | 44 | }); |
@@ -46,14 +46,14 @@ discard block |
||
46 | 46 | /** |
47 | 47 | * Validate exists binary encrypted |
48 | 48 | */ |
49 | - Validator::extend('exists_encrypted', function ($attribute, $value, array $parameters) { |
|
49 | + Validator::extend('exists_encrypted', function($attribute, $value, array $parameters) { |
|
50 | 50 | if (!isset($parameters[0])) { |
51 | 51 | throw new Exception('exists_encrypted requires at least one parameter'); |
52 | 52 | } |
53 | 53 | |
54 | 54 | $field = isset($parameters[1]) ? $parameters[1] : $attribute; |
55 | 55 | |
56 | - $items = DB::select("SELECT count(*) as aggregate FROM `".$parameters[0]."` WHERE AES_DECRYPT(`".$field."`, '".getenv("ENCRYPTION_KEY")."') LIKE '".$value."' COLLATE utf8mb4_general_ci"); |
|
56 | + $items = DB::select("SELECT count(*) as aggregate FROM `" . $parameters[0] . "` WHERE AES_DECRYPT(`" . $field . "`, '" . getenv("ENCRYPTION_KEY") . "') LIKE '" . $value . "' COLLATE utf8mb4_general_ci"); |
|
57 | 57 | |
58 | 58 | return $items[0]->aggregate > 0; |
59 | 59 | }); |