mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Add nullable encrypted casts helper
This commit is contained in:
parent
9872dab2ab
commit
202efc205c
27
app/Casts/EncryptedCast.php
Normal file
27
app/Casts/EncryptedCast.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Casts;
|
||||
|
||||
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
|
||||
|
||||
class EncryptedCast implements CastsAttributes
|
||||
{
|
||||
public function get($model, string $key, $value, array $attributes)
|
||||
{
|
||||
return ! is_null($value) ? decrypt($value) : null;
|
||||
}
|
||||
|
||||
public function set($model, string $key, $value, array $attributes)
|
||||
{
|
||||
return [$key => ! is_null($value) ? encrypt($value) : null];
|
||||
}
|
||||
}
|
@ -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 = [];
|
||||
|
Loading…
Reference in New Issue
Block a user