<?php

namespace Database\Seeders;

use App\Models\FingerprintMachine;
use Illuminate\Database\Seeder;

class FingerprintMachineSeeder extends Seeder
{
    public function run(): void
    {
        $machines = [
            [
                'name' => 'Mesin Fingerprint 1 - Lobby Utama',
                'ip_address' => '192.168.1.201',
                'port' => '4370',
                'connection_type' => 'adms',
                'protocol' => 'adms_push',
                'personnel_target' => 'both',
                'status' => 'online',
                'last_sync' => now()->subMinutes(5),
                'firmware' => 'Revo W-231N v2.1.4',
                'user_count' => 180,
                'log_count' => 4520,
                'latency_ms' => 42,
            ],
            [
                'name' => 'Mesin Fingerprint 2 - Ruang Guru & TU',
                'ip_address' => '192.168.1.202',
                'port' => '4370',
                'connection_type' => 'adms',
                'protocol' => 'adms_push',
                'personnel_target' => 'guru',
                'status' => 'online',
                'last_sync' => now()->subMinutes(8),
                'firmware' => 'Revo W-231N v2.1.4',
                'user_count' => 45,
                'log_count' => 2100,
                'latency_ms' => 38,
            ],
            [
                'name' => 'Mesin Fingerprint 3 - Lab Komputer & RPL',
                'ip_address' => '192.168.1.203',
                'port' => '4370',
                'connection_type' => 'adms',
                'protocol' => 'adms_push',
                'personnel_target' => 'siswa',
                'status' => 'online',
                'last_sync' => now()->subMinutes(12),
                'firmware' => 'Revo W-231N v2.1.3',
                'user_count' => 120,
                'log_count' => 3800,
                'latency_ms' => 55,
            ],
            [
                'name' => 'Mesin Fingerprint 4 - Gedung AKL & TKJ',
                'ip_address' => '192.168.1.204',
                'port' => '4370',
                'connection_type' => 'adms',
                'protocol' => 'adms_push',
                'personnel_target' => 'siswa',
                'status' => 'online',
                'last_sync' => now()->subMinutes(15),
                'firmware' => 'Revo W-231N v2.1.4',
                'user_count' => 95,
                'log_count' => 2900,
                'latency_ms' => 61,
            ],
            [
                'name' => 'Mesin Fingerprint 5 - Bengkel TKR',
                'ip_address' => '192.168.1.205',
                'port' => '4370',
                'connection_type' => 'adms',
                'protocol' => 'adms_push',
                'personnel_target' => 'siswa',
                'status' => 'offline',
                'last_sync' => now()->subDay(),
                'firmware' => 'Revo W-231N v2.0.9',
                'user_count' => 60,
                'log_count' => 1500,
                'latency_ms' => 0,
            ],
            [
                'name' => 'Mesin Fingerprint 6 - Gerbang Barat',
                'ip_address' => '192.168.1.206',
                'port' => '4370',
                'connection_type' => 'adms',
                'protocol' => 'adms_push',
                'personnel_target' => 'both',
                'status' => 'online',
                'last_sync' => now()->subMinutes(3),
                'firmware' => 'Revo W-231N v2.1.4',
                'user_count' => 200,
                'log_count' => 5100,
                'latency_ms' => 47,
            ],
        ];

        foreach ($machines as $machine) {
            FingerprintMachine::updateOrCreate(['name' => $machine['name']], $machine);
        }
    }
}
