Files
ntonpower/app/api/model/Role.php
2026-10-14 14:00:29 +08:00

50 lines
987 B
PHP

<?php
declare(strict_types=1);
namespace app\api\model;
/**
* 角色类
* @mixin \think\Model
*/
class Role extends BaseModel
{
protected $schema = [
'id' => 'int',
'name' => 'string',
'desc' => 'string',
'create_time' => 'int',
'update_time' => 'int',
];
protected $disuse = [
'desc'
];
/**
* 角色菜单关联
* @return \think\model\relation\HasMany
*/
public function RoleToMenu()
{
return $this->hasMany(RoleToMenu::class);
}
/**
* 获取详情
* @param array $data
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getInfo(array $data):array
{
$result = $this->find($data['role_id']);
return $result ? $result->toArray() : [];
}
}