<?php

namespace Database\Seeders;

use App\Models\Category;
use App\Models\CategoryStage;
use App\Models\Department;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;

class CategorySeeder extends Seeder
{
    public function run(): void
    {
        // Get departments
        $hod = Department::where('name', 'HOD')->first();
        $vp = Department::where('name', 'Vice Principal Office')->first();
        $finance = Department::where('name', 'Finance')->first();
        $purchase = Department::where('name', 'Purchase')->first();

        // Category 1: Equipment Request
        $equipment = Category::create([
            'name' => 'Equipment Request',
            'description' => 'Request for new equipment and devices',
        ]);

        CategoryStage::create([
            'category_id' => $equipment->id,
            'department_id' => $hod->id,
            'designation' => 'Head of Department',
            'stage_order' => 1,
        ]);

        CategoryStage::create([
            'category_id' => $equipment->id,
            'department_id' => $vp->id,
            'designation' => 'Vice Principal',
            'stage_order' => 2,
        ]);

        CategoryStage::create([
            'category_id' => $equipment->id,
            'department_id' => $finance->id,
            'designation' => 'Finance Officer',
            'stage_order' => 3,
        ]);

        CategoryStage::create([
            'category_id' => $equipment->id,
            'department_id' => $purchase->id,
            'designation' => 'Purchase Officer',
            'stage_order' => 4,
        ]);

        // Category 2: Service Request
        $service = Category::create([
            'name' => 'Service Request',
            'description' => 'Request for maintenance and support services',
        ]);

        CategoryStage::create([
            'category_id' => $service->id,
            'department_id' => $hod->id,
            'designation' => 'Head of Department',
            'stage_order' => 1,
        ]);

        CategoryStage::create([
            'category_id' => $service->id,
            'department_id' => $vp->id,
            'designation' => 'Vice Principal',
            'stage_order' => 2,
        ]);

        CategoryStage::create([
            'category_id' => $service->id,
            'department_id' => $finance->id,
            'designation' => 'Finance Officer',
            'stage_order' => 3,
        ]);

        // Category 3: Notebook / Stationery
        $stationery = Category::create([
            'name' => 'Notebook / Stationery',
            'description' => 'Request for stationery and office supplies',
        ]);

        CategoryStage::create([
            'category_id' => $stationery->id,
            'department_id' => $hod->id,
            'designation' => 'Head of Department',
            'stage_order' => 1,
        ]);

        CategoryStage::create([
            'category_id' => $stationery->id,
            'department_id' => $purchase->id,
            'designation' => 'Purchase Officer',
            'stage_order' => 2,
        ]);
    }
}
