<?php

namespace App\Database\Seeds;

use CodeIgniter\Database\Seeder;

class UserSeeder extends Seeder
{
    public function run()
    {
        // Cek apakah sudah ada data
        $existing = $this->db->table('users')->where('username', 'admin@simak.id')->get()->getRow();
        
        if (!$existing) {
            $data = [
                'username'   => 'admin@simak.id',
                'name'       => 'Super Admin',
                'email'      => 'admin@simak.id',
                'password'   => password_hash('admin123', PASSWORD_DEFAULT),
                'role'       => 'superadmin',
                'is_active'  => 1,
                'created_at' => date('Y-m-d H:i:s'),
                'updated_at' => date('Y-m-d H:i:s'),
            ];

            $this->db->table('users')->insert($data);
        }
    }
}