<?php

namespace Database\Seeders;

use App\Models\Commons\Menu;
use Illuminate\Database\Seeder;

class RemoveRnDLabsMenuSeeder extends Seeder
{
    public function run(): void
    {
        $tenantId = 1;

        $menu = Menu::where('tenant_id', $tenantId)
            ->where('name', 'R&D Labs')
            ->first();

        if (! $menu) {
            $this->command->warn('R&D Labs 메뉴를 찾을 수 없습니다.');

            return;
        }

        // 하위 메뉴 삭제
        $childCount = Menu::where('parent_id', $menu->id)->count();
        Menu::where('parent_id', $menu->id)->delete();
        $this->command->info("하위 메뉴 {$childCount}개 삭제");

        // 부모 메뉴 삭제
        $menu->delete();
        $this->command->info('R&D Labs 메뉴 삭제 완료');
    }
}
