mirror of
https://gitee.com/ctexthuang/hyperf_rbac_framework_server_ctexthuang.git
synced 2025-12-25 19:27:48 +08:00
33 lines
741 B
PHP
33 lines
741 B
PHP
<?php
|
|
|
|
namespace App\Model\Meta;
|
|
|
|
use Hyperf\Codec\Json;
|
|
use Hyperf\Contract\CastsAttributes;
|
|
|
|
class MetaCast implements CastsAttributes
|
|
{
|
|
/**
|
|
* @param $model
|
|
* @param string $key
|
|
* @param $value
|
|
* @param array $attributes
|
|
* @return AdminUserMeta
|
|
*/
|
|
public function get($model, string $key, $value, array $attributes): AdminUserMeta
|
|
{
|
|
return new AdminUserMeta(empty($value) ? [] : Json::decode($value));
|
|
}
|
|
|
|
/**
|
|
* @param $model
|
|
* @param string $key
|
|
* @param $value
|
|
* @param array $attributes
|
|
* @return array|string
|
|
*/
|
|
public function set($model, string $key, $value, array $attributes): array|string
|
|
{
|
|
return Json::encode($value);
|
|
}
|
|
} |