<?php

namespace App\Database\Seeds;

use CodeIgniter\Database\Seeder;

class UserSeeder extends Seeder
{
    public function run()
    {
        $data = [
            [
                'name'       => 'Administrator',
                'username'   => 'admin',
                'password'   => password_hash('admin123', PASSWORD_DEFAULT),
                'role'       => 'admin',
                'created_at' => date('Y-m-d H:i:s'),
                'updated_at' => date('Y-m-d H:i:s'),
            ],
            [
                'name'       => 'User Biasa',
                'username'   => 'user',
                'password'   => password_hash('user123', PASSWORD_DEFAULT),
                'role'       => 'user',
                'created_at' => date('Y-m-d H:i:s'),
                'updated_at' => date('Y-m-d H:i:s'),
            ]
        ];

        // Simple Queries
        $this->db->table('users')->insertBatch($data);
        
        // Also insert some sample data for master data to make testing easier
        $ruanganData = [
            ['nama_ruangan' => 'Ruang Kepala Sekolah'],
            ['nama_ruangan' => 'Ruang Guru'],
            ['nama_ruangan' => 'Lab Komputer'],
            ['nama_ruangan' => 'Perpustakaan']
        ];
        $this->db->table('ruangan')->insertBatch($ruanganData);

        $sumberDanaData = [
            ['nama_sumber' => 'BOS Pusat'],
            ['nama_sumber' => 'BOS Daerah'],
            ['nama_sumber' => 'Komite Sekolah']
        ];
        $this->db->table('sumber_dana')->insertBatch($sumberDanaData);

        $jenisBarangData = [
            ['nama_jenis' => 'Elektronik'],
            ['nama_jenis' => 'Mebel'],
            ['nama_jenis' => 'Alat Olahraga']
        ];
        $this->db->table('jenis_barang')->insertBatch($jenisBarangData);
    }
}
