<?php

namespace App\Database\Seeds;

use CodeIgniter\Database\Seeder;

/**
 * Seeds support_categories only. Task categories are never seeded;
 * each user creates their own.
 */
class SupportCategorySeeder extends Seeder
{
    public function run(): void
    {
        $now = date('Y-m-d H:i:s');

        $rows = [
            ['title' => 'Technical Issue',         'sort_order' => 10],
            ['title' => 'Account/Login Issue',     'sort_order' => 20],
            ['title' => 'Task Management',         'sort_order' => 30],
            ['title' => 'Notification Issue',      'sort_order' => 40],
            ['title' => 'Feedback/Suggestion',     'sort_order' => 50],
            ['title' => 'Other',                   'sort_order' => 60],
        ];

        foreach ($rows as $row) {
            $existing = $this->db->table('support_categories')
                ->where('title', $row['title'])
                ->get()
                ->getRow();

            if ($existing !== null) {
                continue;
            }

            $this->db->table('support_categories')->insert([
                'title'      => $row['title'],
                'is_active'  => 1,
                'sort_order' => $row['sort_order'],
                'created_at' => $now,
                'updated_at' => $now,
            ]);
        }
    }
}
