where('code', 'super_admin')->first(); if (! $role) { $this->command?->warn('未找到 super_admin,已跳过。'); return; } Menu::query()->where('path', '/teachers/:id')->delete(); $root = Menu::query()->firstOrCreate( ['path' => '/talent', 'parent_id' => null], [ 'name' => 'Talent', 'title' => '老师库与跟进', 'component' => null, 'icon' => 'User', 'sort' => 60, 'visible' => 1, 'keep_alive' => 0, 'permission_code' => null, 'status' => 1, ] ); $teachers = Menu::query()->firstOrCreate( ['path' => '/teachers', 'parent_id' => $root->id], [ 'name' => 'Teachers', 'title' => '老师库', 'component' => 'teachers/index', 'icon' => 'Avatar', 'sort' => 10, 'visible' => 1, 'keep_alive' => 1, 'permission_code' => null, 'status' => 1, ] ); $students = Menu::query()->firstOrCreate( ['path' => '/students', 'parent_id' => $root->id], [ 'name' => 'Students', 'title' => '学员库', 'component' => 'students/index', 'icon' => 'Postcard', 'sort' => 15, 'visible' => 1, 'keep_alive' => 1, 'permission_code' => null, 'status' => 1, ] ); $demands = Menu::query()->firstOrCreate( ['path' => '/demands', 'parent_id' => $root->id], [ 'name' => 'Demands', 'title' => '需求管理', 'component' => 'demands/index', 'icon' => 'ChatLineRound', 'sort' => 20, 'visible' => 1, 'keep_alive' => 1, 'permission_code' => null, 'status' => 1, ] ); $role->menus()->syncWithoutDetaching([$root->id, $teachers->id, $students->id, $demands->id]); $this->command?->info('老师库、学员库与需求管理菜单已更新。'); } }