| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace App\Module\Friend\Databases\Seeders;
- use Dcat\Admin\Models\Menu;
- use Illuminate\Database\Seeder;
- use Illuminate\Support\Facades\DB;
- /**
- * 后台菜单填充器
- */
- class AdminMenuSeeder extends Seeder
- {
- /**
- * 运行填充器
- *
- * @return void
- */
- public function run()
- {
- // 检查是否已存在好友模块菜单
- $existingMenu = Menu::where('title', '好友管理')->first();
- if ($existingMenu) {
- return;
- }
- // 获取父级菜单ID
- $parentId = Menu::where('title', '系统管理')->value('id') ?? 0;
- // 创建好友模块父级菜单
- $friendMenuId = DB::table('admin_menu')->insertGetId([
- 'parent_id' => $parentId,
- 'order' => 10,
- 'title' => '好友管理',
- 'icon' => 'fa-users',
- 'uri' => null,
- 'created_at' => now(),
- 'updated_at' => now(),
- ]);
- // 创建好友关系管理菜单
- DB::table('admin_menu')->insert([
- 'parent_id' => $friendMenuId,
- 'order' => 1,
- 'title' => '好友关系管理',
- 'icon' => 'fa-link',
- 'uri' => 'friend-relations',
- 'created_at' => now(),
- 'updated_at' => now(),
- ]);
- // 创建好友申请管理菜单
- DB::table('admin_menu')->insert([
- 'parent_id' => $friendMenuId,
- 'order' => 2,
- 'title' => '好友申请管理',
- 'icon' => 'fa-paper-plane',
- 'uri' => 'friend-requests',
- 'created_at' => now(),
- 'updated_at' => now(),
- ]);
- }
- }
|