22 lines
544 B
PHP
22 lines
544 B
PHP
<?php
|
|
|
|
namespace App\Models\Casts;
|
|
|
|
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
|
|
use Webauthn\TrustPath\TrustPathLoader;
|
|
|
|
class TrustPath implements CastsAttributes
|
|
{
|
|
public function get($model, string $key, $value, array $attributes): ?\Webauthn\TrustPath\TrustPath
|
|
{
|
|
return $value !== null
|
|
? TrustPathLoader::loadTrustPath(json_decode($value, true))
|
|
: null;
|
|
}
|
|
|
|
public function set($model, string $key, $value, array $attributes)
|
|
{
|
|
return json_encode($value);
|
|
}
|
|
}
|