<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
use App\Models\User;
use App\Models\Branch;

class DatabaseSeeder extends Seeder
{
    public function run(): void
    {
        // Create Admin User
        User::create([
            'name' => 'System Administrator',
            'email' => 'admin@ssrc.org',
            'password' => Hash::make('admin123'),
            'role' => 'Database Admin',
            'is_active' => true,
        ]);

        // Create Operations Manager
        User::create([
            'name' => 'Operations Manager',
            'email' => 'operations@ssrc.org',
            'password' => Hash::make('operations123'),
            'role' => 'Operations Manager',
            'is_active' => true,
        ]);

        // Create 21 Branches (you can adjust these names)
        $branches = [
            'Juba Branch',
            'Aweil Branch',
            'Bor Branch',
            'Malakal Branch',
            'Wau Branch',
            'Yei Branch',
            'Torit Branch',
            'Rumbek Branch',
            'Bentiu Branch',
            'Yambio Branch',
            'Kuajok Branch',
            'Kapoeta Branch',
            'Nimule Branch',
            'Renk Branch',
            'Maridi Branch',
            'Gogrial Branch',
            'Tonj Branch',
            'Abyei Branch',
            'Pibor Branch',
            'Pochalla Branch',
            'Akobo Branch',
        ];

        foreach ($branches as $index => $branchName) {
            Branch::create([
                'name' => $branchName,
                'code' => 'BR' . str_pad($index + 1, 3, '0', STR_PAD_LEFT),
                'is_active' => true,
            ]);
        }
    }
}