Skip to content

Commit e576de1

Browse files
committed
Added a config setting to disable if required
1 parent 38100a6 commit e576de1

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

config/laravel-encryptable.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
<?php
22

33
return [
4+
/*
5+
|--------------------------------------------------------------------------
6+
| Enable field encryption
7+
|--------------------------------------------------------------------------
8+
|
9+
*/
410

11+
'enabled' => env('LARAVEL_ENCRYPTABLE_ENABLED', true),
512
];

src/Traits/LaravelEncryptableTrait.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ trait LaravelEncryptableTrait
1717
public function getAttribute($key)
1818
{
1919
$value = parent::getAttribute($key);
20-
if (in_array($key, $this->encryptable) && trim($value) !== '') {
20+
21+
if (config('laravel-encryptable.enabled') && in_array($key, $this->encryptable) && trim($value) !== '') {
2122
$value = $this->decryptField($value);
2223
}
2324

@@ -33,7 +34,7 @@ public function getAttribute($key)
3334
*/
3435
public function setAttribute($key, $value)
3536
{
36-
if (in_array($key, $this->encryptable) && $value) {
37+
if (config('laravel-encryptable.enabled') && in_array($key, $this->encryptable) && $value) {
3738
$value = encrypt($value);
3839
}
3940

0 commit comments

Comments
 (0)