updateOrCreate( ['code' => 'super_admin'], [ 'name' => '超级管理员', 'remark' => '预置角色;首期按菜单授权全部系统入口(接口不做 permission 校验)', 'sort' => 0, 'status' => 1, ] ); $workbench = Menu::query()->firstOrCreate( ['path' => '/workbench', 'parent_id' => null], [ 'name' => 'Workbench', 'title' => '工作台', 'component' => null, 'icon' => 'Monitor', 'sort' => 10, 'visible' => 1, 'keep_alive' => 0, 'permission_code' => null, 'status' => 1, ] ); $dashboard = Menu::query()->updateOrCreate( ['path' => '/dashboard'], [ 'parent_id' => $workbench->id, 'name' => 'Dashboard', 'title' => '驾驶舱', 'component' => 'dashboard/index', 'icon' => 'Odometer', 'sort' => 10, 'visible' => 1, 'keep_alive' => 0, 'permission_code' => null, 'status' => 1, ] ); $radarMap = Menu::query()->updateOrCreate( ['path' => '/map'], [ 'parent_id' => $workbench->id, 'name' => 'RadarMap', 'title' => '高校雷达网地图', 'component' => 'assets/map/index', 'icon' => 'MapLocation', 'sort' => 20, 'visible' => 1, 'keep_alive' => 1, 'permission_code' => null, 'status' => 1, ] ); $systemRoot = Menu::query()->firstOrCreate( ['path' => '/system', 'parent_id' => null], [ 'name' => 'System', 'title' => '系统管理', 'component' => null, 'icon' => 'Setting', 'sort' => 900, 'visible' => 1, 'keep_alive' => 0, 'permission_code' => null, 'status' => 1, ] ); $systemChildren = [ ['/system/users', 'SystemUsers', '用户管理', 'system/users/index', 10, 'User'], ['/system/roles', 'SystemRoles', '角色管理', 'system/roles/index', 20, 'Key'], ['/system/menus', 'SystemMenus', '菜单管理', 'system/menus/index', 30, 'Menu'], ['/system/dict', 'SystemDict', '数据字典', 'system/dict/index', 40, 'Notebook'], ['/system/audit-logs', 'SystemAuditLogs', '操作日志', 'system/audit-logs/index', 50, 'Tickets'], ]; $menuIds = [$workbench->id, $dashboard->id, $radarMap->id, $systemRoot->id]; foreach ($systemChildren as $row) { $m = Menu::query()->firstOrCreate( ['path' => $row[0], 'parent_id' => $systemRoot->id], [ 'name' => $row[1], 'title' => $row[2], 'component' => $row[3], 'icon' => $row[5], 'sort' => $row[4], 'visible' => 1, 'keep_alive' => 0, 'permission_code' => null, 'status' => 1, ] ); $menuIds[] = $m->id; } $opsRoot = Menu::query()->firstOrCreate( ['path' => '/operations', 'parent_id' => null], [ 'name' => 'Operations', 'title' => '运营管理', 'component' => null, 'icon' => 'Goods', 'sort' => 50, 'visible' => 1, 'keep_alive' => 0, 'permission_code' => null, 'status' => 1, ] ); $menuIds[] = $opsRoot->id; $opsChildren = [ ['/courses', 'OperationsCourses', '课程管理', 'operations/courses/index', 10, 'Notebook'], ['/activities', 'OperationsActivities', '活动管理', 'operations/activities/index', 20, 'Calendar'], ['/news', 'OperationsNews', '资讯管理', 'operations/news/index', 30, 'Reading'], ]; foreach ($opsChildren as $row) { $m = Menu::query()->firstOrCreate( ['path' => $row[0], 'parent_id' => $opsRoot->id], [ 'name' => $row[1], 'title' => $row[2], 'component' => $row[3], 'icon' => $row[5], 'sort' => $row[4], 'visible' => 1, 'keep_alive' => 0, 'permission_code' => null, 'status' => 1, ] ); $menuIds[] = $m->id; } $talentRoot = 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, ] ); $menuIds[] = $talentRoot->id; foreach ( [ ['/teachers', 'Teachers', '老师库', 'teachers/index', 10, 'Avatar'], ['/demands', 'Demands', '需求管理', 'demands/index', 20, 'ChatLineRound'], ] as $row ) { $m = Menu::query()->firstOrCreate( ['path' => $row[0], 'parent_id' => $talentRoot->id], [ 'name' => $row[1], 'title' => $row[2], 'component' => $row[3], 'icon' => $row[5], 'sort' => $row[4], 'visible' => 1, 'keep_alive' => 1, 'permission_code' => null, 'status' => 1, ] ); $menuIds[] = $m->id; } Menu::query()->where('path', '/teachers/:id')->delete(); $role->menus()->sync($menuIds); AdminUser::query()->updateOrCreate( ['username' => 'admin'], [ 'password_hash' => Hash::make('Admin@123456'), 'real_name' => '系统管理员', 'status' => 1, ] ); $admin = AdminUser::query()->where('username', 'admin')->first(); $admin->roles()->sync([$role->id]); } }