From 227054231e44bf85dc12c104e165beb120b7fef7 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Tue, 8 Aug 2023 15:51:17 +0200 Subject: [PATCH] Add custom encrypted castable --- tests/etc/EncryptedCast.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/etc/EncryptedCast.php diff --git a/tests/etc/EncryptedCast.php b/tests/etc/EncryptedCast.php new file mode 100644 index 0000000..ad61413 --- /dev/null +++ b/tests/etc/EncryptedCast.php @@ -0,0 +1,30 @@ + $attributes + */ + public function get(Model $model, string $key, mixed $value, array $attributes): mixed + { + return Crypt::decryptString($value); + } + + /** + * Prepare the given value for storage. + * + * @param array $attributes + */ + public function set(Model $model, string $key, mixed $value, array $attributes): mixed + { + return Crypt::encryptString($value); + } +}