lubo_comment_query/app/Models/Casts/WebAuthnBase64.php
2022-08-08 02:07:57 +08:00

20 lines
486 B
PHP

<?php
namespace App\Models\Casts;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
use function Safe\base64_decode;
class WebAuthnBase64 implements CastsAttributes
{
public function get($model, string $key, $value, array $attributes): ?string
{
return $value !== null ? base64_decode($value) : null;
}
public function set($model, string $key, $value, array $attributes)
{
return $value !== null ? base64_encode($value) : null;
}
}