File tree 1 file changed +5
-4
lines changed
1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 2
2
3
3
namespace betterapp \LaravelDbEncrypter \Traits ;
4
4
5
- use Exception ;
5
+ use Illuminate \Contracts \Encryption \DecryptException ;
6
+ use Illuminate \Contracts \Encryption \EncryptException ;
6
7
use Illuminate \Support \Facades \Crypt ;
7
8
8
9
/**
@@ -29,7 +30,7 @@ public function getAttributeValue($key)
29
30
}
30
31
31
32
// decrypt value before casts
32
- if (in_array ($ key , $ this ->encryptable )) {
33
+ if (in_array ($ key , $ this ->encryptable ) && ! is_null ( $ value ) && $ value !== '' ) {
33
34
$ value = $ this ->decrypt ($ value );
34
35
}
35
36
@@ -130,7 +131,7 @@ private function encrypt($value)
130
131
{
131
132
try {
132
133
$ value = Crypt::encrypt ($ value );
133
- } catch (Exception $ e ) {}
134
+ } catch (EncryptException $ e ) {}
134
135
135
136
return $ value ;
136
137
}
@@ -144,7 +145,7 @@ private function decrypt($value)
144
145
{
145
146
try {
146
147
$ value = Crypt::decrypt ($ value );
147
- } catch (Exception $ e ) {}
148
+ } catch (DecryptException $ e ) {}
148
149
149
150
return $ value ;
150
151
}
You can’t perform that action at this time.
0 commit comments