where('code', 'super_admin')->first(); if (! $role) { $this->command?->warn('未找到 super_admin 角色,已跳过往期回顾菜单。'); return; } $opsRoot = Menu::query()->where('path', '/operations')->whereNull('parent_id')->first(); if (! $opsRoot) { $this->command?->warn('未找到运营管理菜单,已跳过往期回顾菜单。'); return; } $menu = Menu::query()->firstOrCreate( ['path' => '/past-reviews', 'parent_id' => $opsRoot->id], [ 'name' => 'OperationsPastReviews', 'title' => '往期回顾', 'component' => 'operations/past-reviews/index', 'icon' => 'Picture', 'sort' => 25, 'visible' => 1, 'keep_alive' => 0, 'permission_code' => null, 'status' => 1, ] ); $role->menus()->syncWithoutDetaching([$opsRoot->id, $menu->id]); $this->command?->info('往期回顾菜单已挂载到运营管理。'); } }