- Changed super admin detection from role-based to `is_super_admin` flag in AdminUser model
- Added `requireDefaultAdminSiteId()` method to throw validation error when no integration site exists
- Enhanced site deletion to migrate platform role bindings to fallback site and auto-delete site-specific admin accounts
- Made agent line code optional with auto-generation fallback using `{site_code}-agent-{counter}` format
42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
||
|
||
namespace Database\Seeders;
|
||
|
||
use App\Models\AdminUser;
|
||
use Illuminate\Database\Seeder;
|
||
use App\Support\AdminAgentPermissionMenuActionSync;
|
||
use App\Support\AdminDrawPermissionMenuActionSync;
|
||
use App\Support\PlatformSystemRoles;
|
||
use App\Support\SuperAdminAccount;
|
||
|
||
/**
|
||
* 后台 RBAC:平台固定角色 super_admin / agent。
|
||
*
|
||
* 演示账号 **admin** / **123456**(仅限非 production)。
|
||
*/
|
||
final class AdminRbacAndUserSeeder extends Seeder
|
||
{
|
||
public function run(): void
|
||
{
|
||
AdminAgentPermissionMenuActionSync::syncMissing();
|
||
AdminDrawPermissionMenuActionSync::syncMissing();
|
||
|
||
PlatformSystemRoles::ensureAll();
|
||
|
||
$username = 'admin';
|
||
AdminUser::query()->updateOrCreate(
|
||
['username' => $username],
|
||
[
|
||
'name' => '超级管理员',
|
||
'email' => null,
|
||
'password' => '123456',
|
||
'status' => 0,
|
||
],
|
||
);
|
||
|
||
/** @var AdminUser $admin */
|
||
$admin = AdminUser::query()->where('username', $username)->firstOrFail();
|
||
SuperAdminAccount::assign($admin);
|
||
}
|
||
}
|