mirror of
https://gitee.com/ctexthuang/hyperf_rbac_framework_server_ctexthuang.git
synced 2025-12-25 19:27:48 +08:00
first commit
This commit is contained in:
78
app/Model/Meta/AdminUserMeta.php
Normal file
78
app/Model/Meta/AdminUserMeta.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Model\Meta;
|
||||
|
||||
use App\Model\Model;
|
||||
|
||||
/**
|
||||
* @property string $title 标题
|
||||
* @property string $i18n 国际化
|
||||
* @property string $badge 徽章
|
||||
* @property string $icon 图标
|
||||
* @property bool $affix 是否固定
|
||||
* @property bool $hidden 是否隐藏
|
||||
* @property string $type 类型
|
||||
* @property bool $cache 是否缓存
|
||||
* @property bool $copyright 是否显示版权
|
||||
* @property string $link 链接
|
||||
* @property string $componentPath 视图文件类型
|
||||
* @property string $componentSuffix 视图前缀路径
|
||||
* @property string $breadcrumbEnable 是否显示面包屑
|
||||
* @property string $activeName 激活高亮的菜单标识
|
||||
* @property string $auth 前端权限判断,允许访问的权限码
|
||||
* @property string $role 前端权限判断,允许访问的角色码
|
||||
* @property string $user 前端权限判断,允许访问的用户名
|
||||
*/
|
||||
final class AdminUserMeta extends Model
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public bool $incrementing = false;
|
||||
|
||||
/**
|
||||
* @var array|string[]
|
||||
*/
|
||||
protected array $fillable = [
|
||||
'title',
|
||||
'i18n',
|
||||
'badge',
|
||||
'icon',
|
||||
'affix',
|
||||
'hidden',
|
||||
'type',
|
||||
'cache',
|
||||
'copyright',
|
||||
'breadcrumbEnable',
|
||||
'componentPath',
|
||||
'componentSuffix',
|
||||
'link',
|
||||
'activeName',
|
||||
'auth',
|
||||
'role',
|
||||
'user',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array|string[]
|
||||
*/
|
||||
protected array $casts = [
|
||||
'affix' => 'boolean',
|
||||
'hidden' => 'boolean',
|
||||
'cache' => 'boolean',
|
||||
'copyright' => 'boolean',
|
||||
'breadcrumbEnable' => 'boolean',
|
||||
'title' => 'string',
|
||||
'componentPath' => 'string',
|
||||
'componentSuffix' => 'string',
|
||||
'i18n' => 'string',
|
||||
'badge' => 'string',
|
||||
'icon' => 'string',
|
||||
'type' => 'string',
|
||||
'link' => 'string',
|
||||
'activeName' => 'string',
|
||||
'auth' => 'array',
|
||||
'role' => 'array',
|
||||
'user' => 'array',
|
||||
];
|
||||
}
|
||||
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