<?php
defined('BASEPATH') or exit('No direct script access allowed');

class StaffSeeder extends BaseSeeder
{
    public function run()
    {
        $staff = [
            ['firstname' => 'Priya',  'lastname' => 'Sharma', 'email' => 'priya@example.com',  'admin' => 0],
            ['firstname' => 'Rajesh', 'lastname' => 'Kumar',  'email' => 'rajesh@example.com', 'admin' => 0],
            ['firstname' => 'Anjali', 'lastname' => 'Verma',  'email' => 'anjali@example.com', 'admin' => 0],
            ['firstname' => 'Vikram', 'lastname' => 'Singh',  'email' => 'vikram@example.com', 'admin' => 0],
            ['firstname' => 'Neha',   'lastname' => 'Reddy',  'email' => 'neha@example.com',   'admin' => 1],
        ];

        foreach ($staff as $s) {
            if ($this->exists('staff', ['email' => $s['email']])) {
                $this->log("· Exists: {$s['email']}");
                continue;
            }
            $this->db->insert(db_prefix() . 'staff', [
                'email'       => $s['email'],
                'firstname'   => $s['firstname'],
                'lastname'    => $s['lastname'],
                'password'    => app_hash_password('password123'),
                'admin'       => $s['admin'],
                'active'      => 1,
                'datecreated' => date('Y-m-d H:i:s'),
                'phonenumber' => '+91' . rand(7000000000, 9999999999),
            ]);
            $this->log("+ Staff: {$s['firstname']} {$s['lastname']} ({$s['email']})");
        }
        $this->log("Password for all seeded staff: password123");
    }
}
