You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.7 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
namespace Database\Seeders;
use App\Models\Menu;
use App\Models\Role;
use Illuminate\Database\Seeder;
/**
* 老师库与跟进:老师库 + 需求管理;移除老师详情隐藏菜单。
* 用法php artisan db:seed --class=TalentMenusSeeder
*/
class TalentMenusSeeder extends Seeder
{
public function run(): void
{
$role = Role::query()->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('老师库、学员库与需求管理菜单已更新。');
}
}