mirror of
https://github.com/koel/koel
synced 2024-12-23 19:13:06 +00:00
19 lines
481 B
PHP
19 lines
481 B
PHP
<?php
|
|
|
|
namespace App\Casts;
|
|
|
|
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
|
|
use Illuminate\Support\Facades\Crypt;
|
|
|
|
class EncryptedValueCast implements CastsAttributes
|
|
{
|
|
public function get($model, string $key, $value, array $attributes): ?string
|
|
{
|
|
return $value ? Crypt::decrypt($value) : null;
|
|
}
|
|
|
|
public function set($model, string $key, $value, array $attributes): ?string
|
|
{
|
|
return $value ? Crypt::encrypt($value) : null;
|
|
}
|
|
}
|