mirror of
https://gitee.com/ctexthuang/hyperf_rbac_framework_server_ctexthuang.git
synced 2025-12-25 18:17:49 +08:00
first commit
This commit is contained in:
33
app/Model/Meta/MetaCast.php
Normal file
33
app/Model/Meta/MetaCast.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user