feat(admin): 增加玩家密码管理与角色边界
This commit is contained in:
30
app/Support/InvalidPlatformAgentRoleCleanup.php
Normal file
30
app/Support/InvalidPlatformAgentRoleCleanup.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use App\Models\AdminRole;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
final class InvalidPlatformAgentRoleCleanup
|
||||
{
|
||||
public static function run(): int
|
||||
{
|
||||
$agentRoleId = DB::table('admin_roles')
|
||||
->where('scope_type', AdminRole::SCOPE_SYSTEM)
|
||||
->where('slug', PlatformSystemRoles::SLUG_AGENT)
|
||||
->value('id');
|
||||
|
||||
if ($agentRoleId === null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return DB::table('admin_user_site_roles')
|
||||
->where('role_id', (int) $agentRoleId)
|
||||
->whereNotExists(static function ($query): void {
|
||||
$query->selectRaw('1')
|
||||
->from('admin_user_agents as cleanup_uag')
|
||||
->whereColumn('cleanup_uag.admin_user_id', 'admin_user_site_roles.admin_user_id');
|
||||
})
|
||||
->delete();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user