Files
lotteryLaravel/app/Support/PlatformSystemRoles.php
kang a44679665d feat: 增强代理和玩家管理功能
- 在多个控制器中更新权限检查逻辑,确保管理员能够更灵活地管理代理和玩家。
- 在 AdminPlayerStoreController 中引入对玩家创建能力的验证,确保只有具备相应权限的管理员能够创建玩家。
- 更新请求验证逻辑,新增 credit_limit、rebate_rate 和 extra_rebate_rate 字段,以支持更细粒度的玩家管理。
- 在 AgentNodeProfileController 中添加对父代理能力授予的验证,确保子代理的权限在父代理范围内。
- 引入 AgentProfileFieldRules 以简化代理资料更新请求的规则定义,提升代码复用性。
2026-06-04 18:00:50 +08:00

55 lines
1.5 KiB
PHP

<?php
namespace App\Support;
use App\Models\AdminRole;
/** 平台角色管理仅维护的两个内置系统角色。 */
final class PlatformSystemRoles
{
public const SLUG_SUPER_ADMIN = AdminRole::ROLE_SUPER_ADMIN;
public const SLUG_AGENT = 'agent';
/** @return list<string> */
public static function fixedSlugs(): array
{
return [self::SLUG_SUPER_ADMIN, self::SLUG_AGENT];
}
public static function isFixedSlug(string $slug): bool
{
return in_array($slug, self::fixedSlugs(), true);
}
/** 超级管理员:平台内置,同步当前目录中的全部 `prd.*`。 */
public static function ensureSuperAdminRole(): AdminRole
{
$role = AdminRole::query()->updateOrCreate(
[
'slug' => self::SLUG_SUPER_ADMIN,
'scope_type' => AdminRole::SCOPE_SYSTEM,
],
[
'code' => self::SLUG_SUPER_ADMIN,
'name' => '超级管理员',
'description' => '平台内置角色,拥有全部权限',
'status' => 1,
'is_system' => true,
'sort_order' => 10,
'owner_agent_id' => null,
'delegated_from_role_id' => null,
],
);
$role->syncAllActiveMenuActions();
return $role->fresh() ?? $role;
}
public static function ensureAll(): void
{
self::ensureSuperAdminRole();
AgentDefaultRolePermissions::ensurePlatformAgentRole();
}
}