koel/app/Casts/EncryptedValueCast.php

20 lines
481 B
PHP
Raw Normal View History

2024-01-05 16:42:50 +00:00
<?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;
}
}