From 202efc205cd8fb359e11cb72c0a56ee7a6446f48 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 16 May 2023 18:00:39 +1000 Subject: [PATCH] Add nullable encrypted casts helper --- app/Casts/EncryptedCast.php | 27 +++++++++++++++++++++++++++ app/Models/Company.php | 17 +++++++++-------- 2 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 app/Casts/EncryptedCast.php diff --git a/app/Casts/EncryptedCast.php b/app/Casts/EncryptedCast.php new file mode 100644 index 000000000000..1d41b6ce333f --- /dev/null +++ b/app/Casts/EncryptedCast.php @@ -0,0 +1,27 @@ + ! is_null($value) ? encrypt($value) : null]; + } +} diff --git a/app/Models/Company.php b/app/Models/Company.php index a0d926b86f23..0a921451711a 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -11,18 +11,19 @@ namespace App\Models; -use App\DataMapper\CompanySettings; -use App\Models\Presenters\CompanyPresenter; -use App\Services\Notification\NotificationService; use App\Utils\Ninja; +use App\Casts\EncryptedCast; use App\Utils\Traits\AppSetup; -use App\Utils\Traits\CompanySettingsSaver; use App\Utils\Traits\MakesHash; -use Illuminate\Database\Eloquent\Relations\BelongsTo; -use Illuminate\Database\Eloquent\Relations\HasMany; -use Illuminate\Notifications\Notification; +use App\DataMapper\CompanySettings; use Illuminate\Support\Facades\Cache; use Laracasts\Presenter\PresentableTrait; +use App\Utils\Traits\CompanySettingsSaver; +use Illuminate\Notifications\Notification; +use App\Models\Presenters\CompanyPresenter; +use App\Services\Notification\NotificationService; +use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\BelongsTo; /** * App\Models\Company @@ -358,7 +359,7 @@ class Company extends BaseModel 'deleted_at' => 'timestamp', 'client_registration_fields' => 'array', 'tax_data' => 'object', - 'e_invoice_certificate_passphrase' => 'encrypted', + 'e_invoice_certificate_passphrase' => EncryptedCast::class, ]; protected $with = [];