|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
namespace Database\Seeders;
|
|
|
|
|
|
|
|
|
|
|
|
use App\Models\Menu;
|
|
|
|
|
|
use Illuminate\Database\Seeder;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 为已有子菜单补全/修正 Element Plus 图标名(侧栏展示)。
|
|
|
|
|
|
* 用法:php artisan db:seed --class=MenuIconsSeeder
|
|
|
|
|
|
*/
|
|
|
|
|
|
class MenuIconsSeeder extends Seeder
|
|
|
|
|
|
{
|
|
|
|
|
|
public function run(): void
|
|
|
|
|
|
{
|
|
|
|
|
|
$icons = [
|
|
|
|
|
|
'/dashboard' => 'Odometer',
|
|
|
|
|
|
'/map' => 'MapLocation',
|
|
|
|
|
|
'/courses' => 'Notebook',
|
|
|
|
|
|
'/activities' => 'Calendar',
|
|
|
|
|
|
'/news' => 'Reading',
|
|
|
|
|
|
'/teachers' => 'Avatar',
|
|
|
|
|
|
'/students' => 'Postcard',
|
|
|
|
|
|
'/demands' => 'ChatLineRound',
|
|
|
|
|
|
'/crawler' => 'Download',
|
|
|
|
|
|
'/papers' => 'Document',
|
|
|
|
|
|
'/universities' => 'School',
|
|
|
|
|
|
'/banners' => 'Picture',
|
|
|
|
|
|
'/system/users' => 'User',
|
|
|
|
|
|
'/system/roles' => 'Key',
|
|
|
|
|
|
'/system/menus' => 'Menu',
|
|
|
|
|
|
'/system/dict' => 'Notebook',
|
|
|
|
|
|
'/system/audit-logs' => 'Tickets',
|
|
|
|
|
|
'/system/research-directions' => 'Collection',
|
|
|
|
|
|
'/system/grid-members' => 'Coordinate',
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($icons as $path => $icon) {
|
|
|
|
|
|
$count = Menu::query()->where('path', $path)->update(['icon' => $icon]);
|
|
|
|
|
|
if ($count > 0) {
|
|
|
|
|
|
$this->command?->info("{$path} → {$icon}");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 兜底:所有可见子菜单若仍无图标,使用 Menu
|
|
|
|
|
|
Menu::query()
|
|
|
|
|
|
->whereNotNull('parent_id')
|
|
|
|
|
|
->where('status', 1)
|
|
|
|
|
|
->where(function ($q) {
|
|
|
|
|
|
$q->whereNull('icon')->orWhere('icon', '');
|
|
|
|
|
|
})
|
|
|
|
|
|
->update(['icon' => 'Menu']);
|
|
|
|
|
|
|
|
|
|
|
|
$this->command?->info('子菜单图标已更新。');
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|