| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- namespace App\Console\Commands;
- use App\Module\System\Models\AdminMenu;
- use Illuminate\Console\Command;
- class InsertShopAdminMenu extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'admin:insert-shop-menu';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '添加商店模块的后台管理菜单';
- /**
- * Execute the console command.
- *
- * @return int
- */
- public function handle()
- {
- // 获取最大的order值
- $maxOrder = AdminMenu::max('order');
- $nextOrder = $maxOrder + 1;
-
- // 1. 创建商店管理菜单(在游戏运营管理下)
- $shopManageMenu = AdminMenu::firstOrCreate(
- ['title' => '🛒 商店管理', 'uri' => ''],
- [
- 'parent_id' => 260, // 游戏运营管理
- 'order' => $nextOrder++,
- 'icon' => 'fa-shopping-cart',
- 'uri' => '',
- 'show' => 1
- ]
- );
-
- $this->info("创建商店管理菜单: {$shopManageMenu->title}, ID: {$shopManageMenu->id}");
-
- // 2. 创建商店管理子菜单
- $shopSubMenus = [
- [
- 'title' => '商店分类',
- 'uri' => 'shop/categories',
- 'icon' => 'fa-tags'
- ],
- [
- 'title' => '商店商品',
- 'uri' => 'shop/items',
- 'icon' => 'fa-cube'
- ],
- [
- 'title' => '促销活动',
- 'uri' => 'shop/promotions',
- 'icon' => 'fa-percent'
- ],
- [
- 'title' => '购买记录',
- 'uri' => 'shop/purchase-logs',
- 'icon' => 'fa-list-alt'
- ]
- ];
-
- foreach ($shopSubMenus as $subMenu) {
- $menu = AdminMenu::firstOrCreate(
- ['title' => $subMenu['title'], 'uri' => $subMenu['uri']],
- [
- 'parent_id' => $shopManageMenu->id,
- 'order' => $nextOrder++,
- 'icon' => $subMenu['icon'],
- 'uri' => $subMenu['uri'],
- 'show' => 1
- ]
- );
-
- $this->info("创建商店管理子菜单: {$menu->title}, URI: {$menu->uri}");
- }
-
- $this->info('商店模块菜单添加完成!');
-
- return 0;
- }
- }
|