1: <?php
2:
3: namespace Aurora\System\Casts;
4:
5: use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
6: use Illuminate\Support\Str;
7: use Aurora\System\Utils;
8:
9: class Encrypt implements CastsAttributes
10: {
11: public function get($model, $key, $value, $attributes)
12: {
13: $decrypted = Utils::DecryptValue($value);
14: if ($decrypted) {
15: return substr($decrypted, 6);
16: }
17:
18: return false;
19: }
20:
21: public function set($model, $key, $value, $attributes)
22: {
23: return [$key => Utils::EncryptValue(Str::random(6) . $value)];
24: }
25: }
26: