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.

46 lines
1.3 KiB

<?php
namespace Database\Seeders;
use App\Models\Menu;
use App\Models\Role;
use Illuminate\Database\Seeder;
class PastReviewMenusSeeder extends Seeder
{
public function run(): void
{
$role = Role::query()->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('往期回顾菜单已挂载到运营管理。');
}
}